12. Unique Values in Order
Easy
Given numeros, a sorted array that may contain duplicate values, return a new array with each value only once, while preserving increasing order. The original array does not need to be modified.
Example 1
Input: numeros = [1, 1, 2, 2, 4]
Output: [1, 2, 4]
Example 2
Input: numeros = [-2, -2, 0, 3, 3]
Output: [-2, 0, 3]
Constraints
- 0 <= numeros.length <= 10^5
- numeros está em ordem não decrescente.
ArraysTwo pointers
Saved in this browser
Caso 1
numeros =
[1,1,2,2,4]
Expected =
[1,2,4]
Caso 2
numeros =
[-2,-2,0,3,3]
Expected =
[-2,0,3]
Run checks these 2 cases. Submit runs all 6, including hidden ones.