Facebook | Phone Screen | Tuple Combination Sum

Q: Write a function that list any 3 elements that sum to zero, from an array of integers.

Notes:

  1. We need all unique solutions. (-5, -5, 10) is same as (10, -5, -5)
  2. The same element can be used multiple times.

Example
Input: [-5, 1, 10, 2, 3] // array of integers
Output: [(-5, -5, 10), (-5, 2, 3)] // array of tuples

Comments (13)