In a sorted array, if the endpoint sum is too small, advance the left pointer; if too large, move the right one inward.
Read the related guide · · Bookmark this unique URL with Ctrl/Cmd+D.
Two pointers move through an ordered sequence from opposite ends or in the same direction to avoid checking every pair. Experiment with a small example and see each step update.
In a sorted array, if the endpoint sum is too small, advance the left pointer; if too large, move the right one inward.
Read the related guide · · Bookmark this unique URL with Ctrl/Cmd+D.