Task 2 of 9 · 0 solved · 9 to go0%
You can read the problem, but answers are checked only for signed-in students. Sign in to answer →

10.1 HashMap — build a frequency map

Total: 0 / 3 pts
Practice mode — check each part and get hints as you go.
Task

Fill in countWords so that it returns a map from each distinct word to how many times it appears.

Hint: getOrDefault(word, 0) + 1 makes the first occurrence start at 1. The program looks values up by key — never rely on the order of a map.

Your solution