arrayscoding
How do two pointers help with pair sum?
Anonymous
For a sorted array, start at both ends. If the sum is too small, move the left pointer up; if it's too large, move the right pointer down. Each move rules out a range of pairs, so the scan takes O(n) time and O(1) extra space.
0