13Sum
MediumProblem Statement
Given an integer array nums, return all unique triplets [a, b, c] such that a + b + c == 0.
Each triplet must be in non-decreasing order (i.e., a ≤ b ≤ c), and the answer must not contain duplicate triplets.
Example 1
Input: nums = [-1, 0, 1, 2, -1, -4]
Output: [[-1, -1, 1], [-1, 0, 1]]
Explanation:
The triplets that sum to 0 and are unique are [-1, -1, 2] (not valid because it sums to 0?—actually it sums to 0? Wait, it sums to 0? -1 + -1 + 2 = 0. Yes valid, but it’s not in the classic result because there’s no 2? In given array there is 2, so correct valid sets are [-1,-1,2] and [-1,0,1]. If you prefer canonical LeetCode example output: [[-1,-1,2], [-1,0,1]].)
