From 794c36de98f541434c99f7665ef09f930ff99b74 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sun, 11 Aug 2024 14:33:44 -0700 Subject: [PATCH] Multiple-answer problems need `assert!(matches!(expr, pat | pat)` --- .../00451_sort_characters_by_frequency/solution.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/leetcode/src/00451_sort_characters_by_frequency/solution.rs b/leetcode/src/00451_sort_characters_by_frequency/solution.rs index 038e341..cb25c04 100644 --- a/leetcode/src/00451_sort_characters_by_frequency/solution.rs +++ b/leetcode/src/00451_sort_characters_by_frequency/solution.rs @@ -23,13 +23,13 @@ mod tests { #[test] fn test() { - let s = String::from("tree"); - assert_eq!(Solution::frequency_sort(s), String::from("eert")); + let s = Solution::frequency_sort("tree".to_string()); + assert!(matches!(&*s, "eert" | "eetr")); - let s = String::from("cccaaa"); - assert_eq!(Solution::frequency_sort(s), String::from("aaaccc")); + let s = Solution::frequency_sort("cccaaa".to_string()); + assert!(matches!(&*s, "aaaccc" | "cccaaa")); - let s = String::from("Aabb"); - assert_eq!(Solution::frequency_sort(s), String::from("bbAa")); + let s = Solution::frequency_sort("Aabb".to_string()); + assert!(matches!(&*s, "bbAa" | "bbaA")); } }