Opposite Direction Pointers
Start at both ends and move inward. The comparison decides which one moves.
Two Pointers: Two sum on a sorted array
1 + 15 = 16, too big. Only a smaller right value can help, so right moves down.
Cost
- Best
- O(n)
- Average
- O(n)
- Worst
- O(n)
- Space
- O(1)
Before this
Leads to
Topics that need this one first.
Taught by the same lesson
Two Pointers covers these too, in the same run.