3SUM

Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.

Notice that the solution set must not contain duplicate triplets.

Sample Input 1
[-1, 0, 1, 2, -1, -4]
Sample Output 1
[[-1, -1, 2], [-1, 0, 1]]
Sample Input 2
[0, 1, 1]
Sample Output 2
[]
Sample Input 3
[0, 0, 0]
Sample Output 3
[[0, 0, 0]]
Time Limit

1.0 seconds

Memory Limit

256 KB

Constraints