18. 4Sum
Practice 4Sum for free on NudgeCode: Medium, Two Pointers pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Return all distinct quadruplets [a, b, c, d] of values from nums (using four different indices) whose sum equals target. The answer must not contain duplicate quadruplets; order doesn't matter.
Example
nums = [1,0,-1,0,-2,2], target = 0 -> [[-2,-1,1,2],[-2,0,0,2],[-1,0,0,1]]
Constraints
- 1 <= nums.length <= 200
- -10^9 <= nums[i], target <= 10^9