aboutsummaryrefslogtreecommitdiff
path: root/other/sort_char_freq.rs
diff options
context:
space:
mode:
Diffstat (limited to 'other/sort_char_freq.rs')
-rw-r--r--other/sort_char_freq.rs16
1 files changed, 0 insertions, 16 deletions
diff --git a/other/sort_char_freq.rs b/other/sort_char_freq.rs
deleted file mode 100644
index a9d0e13..0000000
--- a/other/sort_char_freq.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-struct Solution;
-
-impl Solution {
- pub fn frequency_sort(s: String) -> String {
- let mut map = std::collections::HashMap::with_capacity(26 * 2);
- s.chars().for_each(|b| * map.entry(b).or_insert(0) += 1);
- let mut v = map.into_iter().map(|(c, n)| (c, n)).collect::<Vec<_>>();
- v.sort_unstable_by_key(|pair| - pair.1);
- v.into_iter().flat_map(|(c, n)| vec![c; n as usize]).collect()
- }
-}
-
-fn main() {
- let s = String::from("tree");
- print!("{}", Solution::frequency_sort(s));
-}