Ctrl K
Problem

Zero-Sum Triples

Medium · Zero-Sum Triples

You are given an integer array `values`. Find every distinct triple of numbers that can be picked from three different positions of the array so that the three numbers add up to zero. Return each triple as a list of three numbers. Two triples made of the same numbers count as the same triple, even if they come from different positions, so each must appear in the answer only once. If no such triple exists, return an empty list. Neither the order of the triples nor the order of numbers inside a triple matters.…

Solve the problem →