About This Pattern
Master the Hash Map pattern by practicing these problems organized by difficulty.Focus on the Key Signals - these are the indicators that tell you when to use this pattern.
Easy (2)
Two Sum
Given an array of integers and a target, return indices of two numbers that add up to target.
Key Signals:
Fast lookup neededComplement searchO(n) solution possible
Word Pattern
Given a pattern and a string s, check if s follows the same pattern (bijection).
Key Signals:
Pattern matchingBijectionTwo hash maps
Medium (1)
Detect Squares
Design data structure to add points and count axis-aligned squares.
Key Signals:
Store point countsFor each pair, find other two cornersMultiply counts