◄ WORLD V · SONNY 5DART 317 · a helldive at the net

THE TWO-POINTER two fingers converging on sorted data — one sweep, no backtracking

On sorted data, many search problems collapse under two pointers converging from the ends. To find a pair summing to a target: start one finger at the smallest value and one at the largest. If the sum is too big, the largest cannot be in any answer with something even larger — retreat the right finger. If too small, advance the left. Each move permanently rules out a value, so the fingers meet after one linear sweep with no backtracking and no extra storage. The monotonic structure of the sorted array is what makes a rejected element rejectable forever — the mechanism spends the order to buy the single pass.

THE TECHNIQUE converge from both ends; each step eliminates one candidate for good

A sorted array and a target. The demo converges two pointers to the pair, eliminating one endpoint per step: live demo


HISTORY & CREDIT the two-finger / opposite-ends technique

“Finding a pair means checking all pairs.” — on sorted data, two converging pointers do it in one sweep: each comparison discards an endpoint that can never be part of the answer. cited

technique · two-pointer / opposite-ends convergence, a foundational trick on sorted or monotone arrays.
kin · the merge step of mergesort; Dijkstra's Dutch-national-flag (three pointers); the linked-list “tortoise and hare.”
now · two-sum on sorted input, container-with-most-water, in-place partition, merging.

Two fingers walking toward each other; every step throws away an endpoint forever. The order of the data pays for the single pass. two-pointer

RECOMMEND FOR I-13 the converging pair, on the compiler

On the canonical compiler, two pointers on sorted [1,2,3,4,6] find the pair summing to 6 — the smaller member is 2 (with 4):

$ i13 run op_twopointer.i13 # converge lo/hi to the pair summing to 6 RUN OK · 97 step(s) · peak stack 6 · call depth 3 pair_lo = 2 -- pair (2,4); each step discarded an endpoint for good
Recommend: the two-pointer is reconstruction-free search that never looks back — i13 converges the fingers on [1,2,3,4,6] and finds the pair (2,4) for target 6. The supplement to correctness: a correct all-pairs search revisits candidates O(n²) times; the two-pointer discards each endpoint permanently and finishes in one linear sweep with no auxiliary memory. It leans on the array's sortedness (a data property, like B39's distinct nodes) to make rejection permanent — which is exactly why it is not a keeper: the load is borne by the sorted data, not by i13's mechanism. A clean, honest member of the theme.