easy
Remove Duplicates from Sorted Array
Given an integer array sorted in non-decreasing order, remove duplicates in place so that each value appears once, keeping the relative order. Return the count k of unique elements; the first k slots must hold them.
Constraints
- 1 ≤ n ≤ 3 · 10^4
- -100 ≤ nums[i] ≤ 100
- O(1) extra space
Examples
in: nums = [0,0,1,1,1,2,2,3]
out: 4, nums = [0,1,2,3,...]
Code it yourself
Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?
Choose an approach to check your pattern recognition, or reveal the discussion when you need help.