DSA · Reimagined
Searching easy time O(n) space O(1)

Two Sum (Sorted)

On a sorted array, start a pointer at each end. If the pair sums too high, move the right pointer in; too low, move the left pointer in. They converge on the answer, or cross with no pair.

1
0
3
1
4
2
6
3
8
4
11
5
15
6

Find two values that add up to 14.

1 / 4

Practice

Machine twin: /dsa-viz-v2/two-sum-sorted.json — the full deterministic run as structured data.