CodeOath
← All problems

3Sum

Medium
arraystwo-pointers

Given an integer array nums, return all unique triplets [a, b, c] such that a + b + c == 0. The solution set must not contain duplicate triplets.

Example:

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

Constraints:

  • 3 <= nums.length <= 3000
  • -10^5 <= nums[i] <= 10^5