Given an integer array and a target, return all unique quadruplets that sum to the target. Sorting plus two nested fixed positions plus two pointers is the standard solution pattern.
nums = array of integers, target = required sum
list of unique quadruplets
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]]
Explanation:
These are the unique quadruplets that sum to 0.
Example 2:
Input:
nums = [2,2,2,2,2] target = 8
Output:
[[2,2,2,2]]
Explanation:
Only one unique quadruplet exists.