🧮Two Pointers
Also known as Two-Pointer Technique, Two Pointer Method
Walking a list with two markers at once. Often one starts at each end.
Think of it like
Think of it like two friends on a bench. They start at the ends and walk toward each other.
Example
Emma checks if the word level reads the same both ways. One marker starts at each end, and they meet in the middle with every letter matching.
Why it matters
It is one of the most common tricks for fast list code. Job interviews ask about it a lot.
Definition
Common mistake
Key takeaways
- 1Two markers. Often at both ends.
- 2Move toward each other. Based on what they see.
- 3One pass. O(n) instead of O(n²).