Coding Challenge

3Sum

Medium
arraytwo-pointerssorting

Find all unique triplets that sum to zero.

Return all unique triplets [a,b,c] from the array such that a + b + c = 0. Do not include duplicate triplets.

Examples

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

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

Constraints

  • 0 <= nums.length

Preparing your coding workspace...