You are given an integer array nums.
Your task is to find all unique triplets [nums[i], nums[j], nums[k]] from nums such that their sum is zero.
Note that:
i, j, and k must be distinct.Return a list of all such unique triplets. The order of triplets in the output does not matter.
[-2, -1, 0, 1, 3]
[ [-1, 0, 1], [-2, -1, 3] ]
The triplets are [-1, 0, 1] because -1 + 0 + 1 = 0, and [-2, -1, 3] because -2 + -1 + 3 = 0.
[-1, 0, 2]
[ ]
No triplet sums to zero.
[0, 0, 0]
[ [0, 0, 0] ]
The only triplet is [0, 0, 0] which sums to zero.
[-2, -1, 0, 1, 3]
[ [-1, 0, 1], [-2, -1, 3] ]