← Pointer Manipulation

Micro-Drill #84 — Converging two pointers

Pointer Manipulation Target: 10s

Converging pointers shrink the search space from both ends. Core of two-sum-sorted and palindrome.

l, r = 0, len(a) - 1
while l < r:
    # process a[l], a[r]
    l += 1; r -= 1

Type it from memory. Go.

Practice Problems

Related Coding Drills

← Micro #83 Micro #85 →