Workspace Frequency Counting
0d
Problem-solving patterns

Frequency Counting

Convert repeated values into counts indexed by key.

Recognition signal

The question mentions duplicates, inventory or matching counts.

Method

Increment the bucket for the next symbol, then query the completed tally.

Worked example

In [2, 7, 2] the entry for 2 changes from 0 to 1 and then 2.

Common mistake

A set loses multiplicity.