Pattern 1 - Opposite Direction

Pointers start at ends and move toward each other.

Opposite direction pointers start at both ends, moving toward each other.

When to use: Pairs where search space narrows from both ends.

Examples: Two Sum II, Container With Most Water, Valid Palindrome, 3Sum.

Template:

left = 0, right = n - 1
while left < right:
    if condition based on arr[left], arr[right]:
        process result
    if need larger: left++
    else: right--

Each iteration moves at least one pointer. O(n)O(n) total.