Facebook | Phone Screen | Tuple Combination Sum

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2017-06-17Added By Anonymous
Source: Link

Company: Meta (Facebook)
Role: unknown
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

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