#C2449. Four Sum Problem
Four Sum Problem
Four Sum Problem
You are given an array of integers and a target integer. Your task is to find all unique quadruplets [a, b, c, d] in the array that satisfy the equation:
\(a+b+c+d = \text{target}\)
Each quadruplet must be sorted in non-decreasing order and the solution set must not contain duplicate quadruplets.
Note: The order of the quadruplets in the output does not matter, but each quadruplet should be printed in non-decreasing order.
inputFormat
The input is read from standard input (stdin) and has the following format:
n target num1 num2 ... numn
Here, the first line contains two integers: n (the number of elements in the array) and target (the target sum). The second line contains n space-separated integers representing the array.
outputFormat
Print all unique quadruplets found, one per line. Each quadruplet should be printed as four space-separated integers in non-decreasing order. If no quadruplet exists that satisfies the condition, output nothing.
## sample6 0
1 0 -1 0 -2 2
-2 -1 1 2
-2 0 0 2
-1 0 0 1
</p>