Remove Duplicates from Sorted Array
Easy
Arrays
Array
Two Pointers
Given a sorted array, remove duplicates in-place and return the new length. Print the unique elements space-separated.
Constraints
1 ≤ nums.length ≤ 3 × 10^4
Examples
Example 1:
Input: 1 1 2
Output: 1 2
Example 2:
Input: 0 0 1 1 1 2 2 3 3 4
Output: 0 1 2 3 4
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console