aboutsummaryrefslogtreecommitdiff
path: root/other/top_k_freq_words.rs
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-06-27 12:23:02 -0600
committerJack Sangdahl <[email protected]>2025-06-27 12:23:02 -0600
commita96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch)
treee2a2b3f49f9fb741be81415266ac93e74cff42ec /other/top_k_freq_words.rs
parent694ad5ed71edcb1deccab54b72d706b779918276 (diff)
downloadleetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz
leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/top_k_freq_words.rs')
-rw-r--r--other/top_k_freq_words.rs26
1 files changed, 0 insertions, 26 deletions
diff --git a/other/top_k_freq_words.rs b/other/top_k_freq_words.rs
deleted file mode 100644
index 606c237..0000000
--- a/other/top_k_freq_words.rs
+++ /dev/null
@@ -1,26 +0,0 @@
-use std::collections::BinaryHeap;
-use std::collections::HashMap;
-
-struct Solution;
-
-impl Solution {
- pub fn top_k_frequent(words: Vec<String>, k: i32) -> Vec<String> {
- let mut word_to_freq = HashMap::<String, i32>::new();
- for w in words {
- *word_to_freq.entry(w).or_default() += 1;
- }
- let mut heap = BinaryHeap::<(i32, String)>::new();
- for (word, freq) in word_to_freq {
- heap.push((-freq, word));
- if heap.len() > k as usize {
- heap.pop();
- }
- }
- let mut ans: Vec<String> = vec![];
- while let Some((_freq, word)) = heap.pop() {
- ans.push(word);
- }
- ans.reverse();
- ans
- }
-}