quest

Sign in to start training

quest keeps your progress, streaks, and scores tied to your account — so you can pick up on any device.

Synced everywhere. Progress follows you across laptop and phone.
Streaks & stats. See your daily run and every score over time.
Your profile. A name and avatar for the work you do here.

We only use Google to sign you in and sync progress. No posting, no contacts — ever.

Core Beginner

05  Collections

Work with the two collections you'll reach for most: find a maximum safely, then tally word frequencies.

Step 2 / 2

Count occurrences of each word in word_count.

Hints
  • HashMap entry API: *map.entry(key).or_insert(0) += 1;
05_collections.rs
Reset to starterCompiled in a sandbox; hidden checks must pass.
Reveal solution
use std::collections::HashMap;

fn word_count(words: &[&str]) -> HashMap<String, u32> {
    let mut counts = HashMap::new();
    for w in words {
        *counts.entry(w.to_string()).or_insert(0) += 1;
    }
    counts
}