3 Sum
Sort the array, fix one value at a time, and use two pointers on the remaining range. Skip duplicate anchors and duplicate pointer values so the result contains unique triplets only.
Return all unique triplets in an array whose sum is zero.
Tagged with sorting
Sort the array, fix one value at a time, and use two pointers on the remaining range. Skip duplicate anchors and duplicate pointer values so the result contains unique triplets only.
Return all unique triplets in an array whose sum is zero.
Sort intervals by start, then compare each interval with the current merged tail. Extend the tail end when ranges overlap; otherwise append a new interval.
Merge all overlapping intervals and return the condensed list.