Skip to content
Codeloom

Topics / Two Pointers

↔️

Two Pointers

Two indices walking an array — the technique behind 3Sum, palindrome checks, and container problems.

Why learn Two Pointers?

  • Converts many O(n²) brute forces into O(n) one-pass solutions.

  • A single pattern that unlocks 30+ classic problems.

  • Appears constantly in mid-level interviews.

What you can build with Two Pointers

Sorted-array pair / triple problems Palindrome and substring checks In-place array modification (remove duplicates, move zeros)

Two Pointers tutorials

4 articles · page 1 of 1

Hand-written tutorials, ordered as a recommended learning path.

  1. 01 Sliding Window Master the sliding window technique with fixed and variable window patterns, two pointer variants, and reusable templates for solving LeetCode problems.
  2. 02 Move Zeroes Solve Move Zeroes in O(n) time and O(1) space using a write pointer. Includes walkthrough, edge cases, and interview tips.
  3. 03 Remove Duplicates Solve Remove Duplicates from Sorted Array in O(n) time and O(1) space with the two-pointer write-pointer pattern. Includes walkthrough, edge cases, and complexity.
  4. 04 Two Pointers Master every two pointer pattern for LeetCode: opposite-end, same-direction, and fast/slow pointers with templates, complexity analysis, and 15+ mapped problems.