Problem statement
Given an integer array, return every unique triplet whose values add up to zero.
The lawful route
Sort the evidence, anchor one value, then use two boundaries to find each lawful pair while skipping duplicate values.
Invariant
Every committed triplet is sorted, unique, and sums to zero.
Proof vocabulary used
- Derived Working State
- Anchor
- Two Pointers
- Duplicate Control
- Invariant
Complexity
Time O(n²) · Space O(1), excluding output