3Sum

Given an integer array nums, return every distinct triplet [nums[i], nums[j], nums[k]] such that i, j, and k are different and the three values add up to 0.

The output should not contain duplicate triplets, even if the input contains repeated numbers.

Examples
Input: [-1,0,1,2,-1,-4]
Output: [[-1,-1,2],[-1,0,1]]
Hints
Related Problems

3Sum

Given an integer array `nums`, return every distinct triplet `[nums[i], nums[j], nums[k]]` such that `i`, `j`, and `k` are different and the three values add up to `0`.