3Sum

Given an integer array nums, return all distinct triplets [nums[i], nums[j], nums[k]] such that i, j, and k are unique indices and the sum of nums[i], nums[j], and nums[k] is zero. The solution set must not contain duplicate triplets.

Constraints

  • 3 <= nums.length <= 3000
  • -10^5 <= nums[i] <= 10^5
Auto-saved · 2 lines
class Solution:
def threeSum(self, nums: List[int]) -> List[List[int]]:
Console

Click Run to execute sample tests.