 All Problems
Remove Duplicates from Sorted Array
easy
arrays
two pointers
amazon
microsoft
google
facebook

Given a sorted array nums, remove duplicates in-place so each element appears only once. Return k (the count of unique elements). Print the first k elements.

Example 1:

Input:  1 1 2
Output: 2
        1 2

Example 2:

Input:  0 0 1 1 1 2 2 3 3 4
Output: 5
        0 1 2 3 4

Input format: Space-separated sorted integers.

Output format: First line = k. Second line = first k elements.

Run to check your code against the sample cases, or submit to run every case