When NOT to Use

Avoid forcing this pattern

Avoid forcing this pattern when:

  • Unsorted array without sort budget: If you can't sort first and need pair relationships, use hash map instead. Sorting adds O(nlogn)O(n \log n).
  • Need ALL pairs, not just one: Two pointers finds one solution. For every valid pair, you need nested iteration or hash-based approaches.
  • Non-comparable elements: If elements can't be ordered, the "move based on comparison" logic fails. Use hash-based lookups instead.