LC 217 looks trivially easy — but FAANG interviewers use it to probe your hashset vs sorting instincts, your ability to articulate space-time trade-offs, and whether you can spot the follow-up traps in LC 219 and LC 220. Full solutions in Python and JavaScript with deep explanation.
LeetCode 128 — Find the longest consecutive integer sequence in O(n) using a HashSet. The trick: only start counting from numbers where num-1 is NOT in the set, so each element is visited at most twice total across the entire algorithm.
Simulate a snake game on a grid where the snake eats food to grow and dies if it hits walls or itself. Uses a deque for O(1) head/tail and a set for O(1) body collision checks.
Design a phone directory managing available and allocated numbers with O(1) get, check, and release using a queue of free numbers and a boolean availability array.