Mental Model
Count how many times each item appears using a simple box to keep track.
Analogy: Imagine sorting colored balls into boxes labeled by color and counting how many balls go into each box.
Input array: [a, b, a, c, b]
Hash map (frequency counter):
{
a: 2,
b: 2,
c: 1
}