...

/

Sum of Three Values

Sum of Three Values

Try to solve the 3Sum problem.

Statement

Given an integer array nums, find and return all unique triplets [nums[i], nums[j], nums[k]], where the indexes satisfy i≠ \neq j, i≠\neq k, and j≠\neqk, and the sum of the elements nums[i] + nums[j] + nums[k] == 0.

Constraints:

  • 3≤3 \leq nums.length ≤500\leq 500

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

Examples