Below is a high-yield, pattern-driven set of two pointers problems. This covers all core concepts:
- opposite-direction pointers
- same-direction (fast/slow)
- partitioning
- deduplication
- linked list cycle detection
- in-place array manipulation
1. Opposite Direction (Sorted Arrays)
Core Skill
- One pointer left, one right
- Move based on condition
Problems
- Two Sum II - Input Array Is Sorted
- Valid Palindrome
Pattern
l, r = 0, len(nums) - 1
while l < r:
if condition:
l += 1
else:
r -= 1
Insight
- Works when array is sorted or symmetric