Skip to content

Instantly share code, notes, and snippets.

@samueltardieu
Created February 23, 2023 11:59
Show Gist options
  • Save samueltardieu/38c261353b3e2aec28a7a87a83cf08ab to your computer and use it in GitHub Desktop.
Save samueltardieu/38c261353b3e2aec28a7a87a83cf08ab to your computer and use it in GitHub Desktop.
fn count_chars(input: &[&str]) -> HashMap<char, usize> {
let mut freq: HashMap<char, usize> = HashMap::default();
for line in input {
for c in line.chars() {
*freq.entry(c).or_default() += 1;
}
}
freq
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment