Back
4Sum
Find all unique quadruplets in the array which gives the sum of target.
Java
Description
Solution
My Code
4Sum
Find all unique quadruplets in the array which gives the sum of target.
Example 1:
Input:
{"nums":[1,0,-1,0,-2,2],"target":0}
Output:
[[-2,-1,1,2],[-2,0,0,2],[-1,0,0,1]]
Viz
Tests
Run
Input
Standard
Target 8
No Solution
Custom
{"nums":[1,0,-1,0,-2,2],"target":0}
arr =
{"nums":[1,0,-1,0,-2,2],"target":0}
Status
Start 4Sum
Target
0
Current Sum
?
Sorted Array
1
0
0
1
-1
2
0
3
-2
4
2
5
i (first)
j (second)
L/R (two pointers)
Found
Found Quadruplets (0)
No quadruplets found yet
Variables
Variable
Value
target
0
Depth
Function Call
Stack empty
0/41
0.5x
1x
2x
4x