Skip to content
Veltoryx Technologies
ProProblem 24● MediumLeetCode #15 ↗3 min readUpdated 30 October 2026

3Sum

Find every unique triplet that sums to zero by sorting, fixing one anchor and squeezing a pair on its right.

01The problem

Return all unique triplets [a, b, c] from nums with a + b + c = 0, using three different positions. The result must not contain duplicate triplets, even when the input repeats values.

InputOutput
[-1, 0, 1, 2, -1, -4][[-1, -1, 2], [-1, 0, 1]]
[0, 0, 0][[0, 0, 0]]

Constraints: 3 to 3000 values, each between −100,000 and 100,000.

Loading the rest of the lesson…