var fourSum = function (nums, target) {
const len = nums.length
nums = nums.sort((a, b) => a - b)
if (len < 4) return []
const result = new Set()
for (let j = 0; j < len; j++) {
const value = nums[j]
for (let i = j + 1; i < len; i++) {
const item = nums[i]
const aim = target - item - value
let left = i + 1
let right = len - 1
while (left < right) {
const sum = nums[left] + nums[right]
if (sum === aim) {
result.add([value, item, nums[left], nums[right]].toString())
left++
right--
} else if (sum > aim) {
right--
} else if (sum < aim) {
left++
}
}
}
}
return Array.from(result).map(item =>
item.split(',')
)
};