Practice Remove Duplicates from Sorted Array
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Given nums sorted in non-decreasing order, remove duplicates in place while preserving the unique values in sorted order. Put those values into the first k positions and return k, the number of unique values. Positions at or beyond k are ignored; the judge checks the returned count and the first k entries.
Source: Remove Duplicates from Sorted Array on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [1,1,2]
Output
2, nums = [1,2,_]
# Example 2
Input
nums = [0,0,1,1,1,2,2,3,3,4]
Output
5, nums = [0,1,2,3,4,_,_,_,_,_]
Constraints
1 <= nums.length <= 3 * 10^4
-100 <= nums[i] <= 100
nums is sorted in non-decreasing order.
Related LeetCode Problems
Practice more problems similar to Remove Duplicates from Sorted Array.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.