Problem Description

3Sum

Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.

Notice that the order of the output and the order of the triplets does not matter.

Example:

Input: [-1, 0, 1, 2, -1, -4],

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

Code Editor