AlgoFrames

Build a frequency map

Warm-up · Trace the algorithm · about 6 min

Follow a frequency map as it reads [4, 2, 4, 4, 2, 9]. The map has 7 buckets and hashes a key with key mod 7. Answer each question before the step plays.

Example 1

Input:

{"values":[4,2,4,4,2,9]}

Output:

{"2":2,"4":3,"9":1}

Constraints

  • The trace uses the input shown.

Learn the idea first: Hash sets and maps in practice: counting, lookup, deduplication, a visual lesson.

More Hash sets and maps in practice: counting, lookup, deduplication problems