Two Pointers

Noun · Development

Definitions

  1. An algorithmic technique using two indices that traverse an array from different positions or at different speeds to solve problems in O(n) time instead of O(n²). Patterns include: converging pointers (from both ends), fast/slow pointers (cycle detection), and sliding window. A fundamental coding interview pattern.

    In plain English: Using two moving markers in an array to efficiently find pairs, detect cycles, or solve problems without nested loops.

    Example: "To find if a sorted array has a pair summing to target, use converging two pointers from both ends — O(n) instead of nested loops."

Related Terms