04 Try it yourself Interactive
The two amber cells are the pair being added right now, and the labels underneath show where each pointer stands. Grey cells have been ruled out and will never be looked at again. It opens on the nested loop so you can count its checks first; switch to the Two pointers tab to watch the walk reach the same answer in far fewer. Press Next to advance and Back to undo. Nothing moves on its own.