3Sum

Try to solve the 3Sum problem.

Statement

Given an integer array, nums, find and return all unique triplets [nums[i], nums[j], nums[k]], such that i \neq j, i \neq k, and j \neq k and nums[i] + nums[j] + nums[k] ==0== 0.

Note: The order of the triplets in the output does not matter.

Constraints:

  • 33 \leq nums.length 500\leq 500

  • 103-10^3 \leq nums[i] 103\leq 10^3

Examples

Create a free account to view this lesson.

Continue your learning journey with a 14-day free trial.

By signing up, you agree to Educative's Terms of Service and Privacy Policy