You are given an array nums of n integers, find all unique quadruplets [a, b, c, d] in nums such that a + b + c + d equals a given target integer.
The solution set must not contain duplicate quadruplets. You may return the answer in any order.
nums = [1, 0, -1, 0, -2, 2]
target = 0
[ [-2, -1, 1, 2], [-2, 0, 0, 2], [-1, 0, 0, 1] ]
The quadruplets (-2, -1, 1, 2), (-2, 0, 0, 2), and (-1, 0, 0, 1) each sum up to 0.
nums = [2, 2, 2, 2, 2]
target = 8
[ [2, 2, 2, 2] ]
The only unique quadruplet that sums to 8 is (2, 2, 2, 2).
nums = [0, 0, 0, 0]
target = 0
[ [0, 0, 0, 0] ]
The only unique quadruplet is (0,0,0,0) which sums to 0.
nums = [1, 0, -1, 0, -2, 2]
target = 0
[ [-2, -1, 1, 2], [-2, 0, 0, 2], [-1, 0, 0, 1] ]