When to Use

Pattern triggers

Look for these signals in the problem:

  • "Reverse" a list or portion: Pointer manipulation reverses in-place without extra space.
  • "Detect cycle" in sequence: Fast and slow pointers (Floyd's algorithm) detect cycles in O(1)O(1) space.
  • "Find middle" element: Two-pointer technique finds middle in single pass.
  • "Merge sorted" lists: Linked list merge is simpler than array merge (no shifting).
  • "Remove nth from end": Two pointers with n-gap find the target in one pass.