#C4539. Four Sum: Find Quadruplets That Sum to Zero

    ID: 48088 Type: Default 1000ms 256MiB

Four Sum: Find Quadruplets That Sum to Zero

Four Sum: Find Quadruplets That Sum to Zero

You are given an array of n integers. Your task is to find all unique quadruplets \( [a, b, c, d] \) in the array such that:

\(a + b + c + d = 0\)

The quadruplets should be returned in lexicographical order (i.e. sorted in ascending order within each quadruplet and the list of quadruplets itself is sorted).

Note: The solution must not contain duplicate quadruplets.

inputFormat

The first line contains a single integer n representing the number of elements in the array. The second line contains n space-separated integers.

outputFormat

Output the list of quadruplets that sum to zero in the Python list format. For example, if there are quadruplets, the output might look like:

[[-1, -1, 0, 2], [-2, 0, 0, 2]]

If no quadruplets exist, output an empty list: [].

## sample
6
-1 0 1 2 -1 -4
[[-1, -1, 0, 2]]