Loading...
Loading...
Loading...
A ledger lists signed amounts. Find every set of three amounts that add up to zero. Print each set once, with the amounts in non-decreasing order, one set per line, and the sets in increasing order. If there is no set, print NONE.
Example
Input
-1 0 1 2 -1 -4
Output
-1 -1 2 -1 0 1
Two triplets: -1 -1 2 and -1 0 1.
Try the problem first. Open one hint at a time.
Sort the list, fix one value, then use pair sum on the values to its right.
Skip a fixed value that equals the previous one, and after a match skip equal values.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor