impl Solution { fncompute_frequency(s: &String) ->i32 { letmut min_char = std::i32::MAX; letmut ans = 0; for c in s.chars() { if (c asi32) < min_char { min_char = c asi32; } } for i in0..s.len() { if s.bytes().nth(i).unwrap() asi32 == min_char { ans += 1; } } return ans; }
pubfnnum_smaller_by_frequency(queries: Vec<String>, words: Vec<String>) -> Vec<i32> { let (mut ans, mut cnt) = (vec![], vec![0; 11]); for w in &words { letmut i = Self::compute_frequency(w) - 1; while i >= 0 { cnt[i asusize] += 1; i -= 1; } } for q in &queries { let val = Self::compute_frequency(q); ans.push(cnt[val asusize]); } return ans; } }