Three Sum
Fix one element, run two-sum on the rest. Skip duplicates.
Two Pointer Problems: Three sum to zero
-4 + -1 + 2 = -3, short of 0. Only a bigger left value can help, so left moves up.
Cost
- Best
- O(n^2)
- Average
- O(n^2)
- Worst
- O(n^2)
- Space
- O(1)
Before this
Taught by the same lesson
Two Pointer Problems covers these too, in the same run.