3
8
12
17
21
26
30
[0][1][2][3][4][5][6]
Concept
▸1left ← 02right ← n - 13while left < right:4 inspect arr[left] and arr[right]5 decide: move left++ or right--6 (occasionally both)7stop when left ≥ right
state
- n7
warming up the animation
▸1left ← 02right ← n - 13while left < right:4 inspect arr[left] and arr[right]5 decide: move left++ or right--6 (occasionally both)7stop when left ≥ right
A two-pointer walk uses just two indices. Most often: one at the start, one at the end.