AAlgoLoopSpaced repetition for LeetCode

Hash Map / Set

Hash maps and sets trade memory for O(1) average lookups, insertions, and membership tests. Reach for one whenever you catch yourself asking 'have I seen this before?' or 'how many times?' — they turn nested-loop searches into a single pass.

22 LeetCode problems solved with the Hash Map / Set pattern. Practice them with spaced repetition so the pattern sticks.

See the full solution

The complete approach, reference solutions in 5 languages, and a step-by-step visualization — then add this problem to your spaced-repetition schedule.

Start free →