3Sum
MediumAcceptance Rate 32.8%
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.Examples
Example 1
Input
nums = [-1,0,1,2,-1,-4]
Output
[[-1,-1,2],[-1,0,1]]
Constraints
0 <= nums.length <= 3000-10^5 <= nums[i] <= 10^5