When Two Pointers Fails

Recognizing problems that need different approaches.

Two pointers fails when:

Unsorted without monotonic property: Need hash maps if sorting changes answer.

All pairs needed: Can't avoid O(n2)O(n^2).

Non-monotonic constraints: Product with negatives may miss solutions.

Pointer movement unclear: If moving doesn't narrow search space, rethink.

Alternatives: Hash maps for unsorted two-sum, sliding window for subarrays, binary search for jumps.