Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 51s1 days 16 hours 1 minutes 51 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 51s1 days 16 hours 1 minutes 51 seconds.

Sign in to watch this lesson
Algorithms - Arrays · 4:48
Two indices that only ever move one way turn quadratic pair searches into linear scans. We find a pair summing to 15 in a sorted array by watching each comparison wipe out a whole row or column of the pair grid, prove why that is safe and linear, and race it against checking every pair. Then the same-direction version, where the left pointer chases the right one, plus merging, three-sum and the classic traps.