55. 3Sum
Medium
Given an array numeros, return all triples of values that are distinct by position whose sum is zero. Each triple must be in ascending order and may not appear more than once in the result. Also sort the result in lexicographic order of the triples.
Example 1
Input: numeros = [-2, 0, 1, 1, 2]
Output: [[-2, 0, 2], [-2, 1, 1]]
Example 2
Input: numeros = [1, 2, 3]
Output: []
Constraints
- 0 <= numeros.length <= 3000
- -10^5 <= numeros[i] <= 10^5
ArraysSortingTwo pointers
Saved in this browser
Caso 1
numeros =
[-2,0,1,1,2]
Expected =
[[-2,0,2],[-2,1,1]]
Caso 2
numeros =
[1,2,3]
Expected =
[]
Run checks these 2 cases. Submit runs all 6, including hidden ones.