3Sum
Find all unique triplets in the array which gives the sum of zero.

30:00

3Sum
medium
Topics
Companies

Find all unique triplets in the array which gives the sum of zero.

Example 1:
Input: [-1,0,1,2,-1,-4]
Output: [[-1,-1,2],[-1,0,1]]
Constraints:
  • 3nums.length30003 \leq \text{nums.length} \leq 3000

  • 105nums[i]105-10^5 \leq \text{nums}[i] \leq 10^5

Input
arr =[-1,0,1,2,-1,-4]
Status

Start 3Sum

Current Sum (i+L+R)

?

Sorted Array
-1

0

0

1

1

2

2

3

-1

4

-4

5

Found Triplets (0)
No triplets found yet
Variables
No variables to display
DepthFunction Call
Stack empty
0/34