#K52147. Zero Sum Pairs
Zero Sum Pairs
Zero Sum Pairs
Given a list of integers, your task is to find all unique pairs of numbers that sum up to zero. A pair is considered unique if it hasn't been reported before regardless of the order of the numbers (i.e. the pair (a, b) is considered the same as (b, a)).
If the number 0 appears at least twice, include the pair (0, 0)
exactly once in your output. The output should list these pairs in ascending order, first by the first element and then by the second element.
If no valid pair exists, do not output anything.
inputFormat
The first line of input contains an integer N
representing the number of integers. The second line contains N
space-separated integers.
outputFormat
For each unique zero-sum pair, print a line containing two space-separated integers where the first integer is less than or equal to the second. The pairs must be printed in ascending order (sorted by the first element, then by the second element). If there are no such pairs, output nothing.## sample
7
3 -3 4 -4 2 -2 5
-4 4
-3 3
-2 2
</p>