Meet in the middle
Start at opposite ends. Compare, then move both pointers closer together.
Palindromes · pair sumsOne scan. Two positions. Clear progress.
Use two indexes to cut away impossible work. The essential question is simple: after comparing the current values, which pointer can safely move?
Three movement patterns
The data and goal decide where each pointer begins and when it advances.
Start at opposite ends. Compare, then move both pointers closer together.
Palindromes · pair sumsOne pointer explores every item; the other marks where the next kept result belongs.
In-place filtering · dedupingKeep one pointer in each sorted sequence. Advance the one that is behind.
Intersections · mergingPattern 01 · inward pointers
Ignore punctuation and casing, then compare the outside characters. A mismatch settles the answer immediately.
Pattern 02 · slow + fast
The read pointer always advances. The write pointer moves only when a new value deserves a place in the compacted prefix.
Pattern 03 · parallel pointers
Discard only the smaller current value: it cannot appear later in the other sorted input.
INTERSECTION [1]
Match: save this value and advance both pointers.Every branch must advance at least one pointer. That prevents a stalled loop and bounds the work.
Say what has already been processed or proved. It makes each pointer move easier to justify.
Sorted inputs, permitted characters, and in-place constraints change the right implementation.