Triplets that sum to zero

Question

Given an array of n distinct elements, can you find all the triplet combinations that sum to zero?
For example:

Input: [0, -1, 2, -3, 1]
Output: 
0 -1 1
2 -3 1

Input: [1, -2, 1, 0, 5]
Output: 1 -2  1

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now