Find a lesson, question or project

Start typing to search published content and planned structures.

↑ ↓ moveEnter openEsc close
01 / WHAT IT SOLVES

Boundary comparisons, sorted pair searches, merging, read/write updates, and fast/slow linked-list traversal.

02 / HOW TO RECOGNIZE IT
  • sorted input with a safe elimination rule
  • preserve order in place
  • compare from two positions
  • merge two sequences
  • find a linked-list middle or cycle
03 / PROTECT THIS INVARIANT

Define what each pointer means and which positions are settled or candidates can safely be discarded; the exact promise depends on the problem.

04 / EXPECTED COST

Often O(n) or O(n + m) time. Typical auxiliary space: Often O(1), excluding output.

JAVA STARTING POINT

A template to adapt, not memorize.

Java
int left = 0;
int right = values.length - 1;
while (left < right) {
    // Inspect both boundaries and move at least one pointer.
}

Common mistakes

  • Moving without a safe elimination rule
  • Using sorted pair-sum moves on unsorted input
  • Losing stable order
  • Not advancing on equal values

PUBLISHED / 08

Learn in this order.

Available articles always appear before the publishing plan.

PLANNED PRACTICE

What comes after the published lessons.

  1. Two sum in a sorted arrayPlanned, not yet published
  2. Container with most waterPlanned, not yet published