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
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.