- Two Sum with HashMap is O(n) time, O(n) space
- Two Pointer needs sorted array, but uses O(1) space โ good answer when interviewer asks "can you do better on space?"
- Three Sum โ fix
i, use two pointers for the rest - Four Sum โ fix
iandj, use two pointers for the rest - Same pattern, just more anchor points
Full breakdown here.