4Sum
mediumFind all unique quadruplets that sum to target
Four Sum
Key Insight
Fix two numbers with nested loops, then use converging two pointers for the remaining pair. Sort + skip duplicates.
Step 1Sort Array
Sorted, target = 0
-2
0-1
10
21
32
4Sort array. Target=0. Fix two outer indices, use two pointers inside.
1 / 6