Dashboard
LC #26
Remove Duplicates from Sorted Array
Pattern · ?AmazonMicrosoftGoogle
Problem
Remove duplicates from a sorted array in-place and return the count of unique elements.
Constraints
- 1 ≤ n ≤ 3 × 10⁴
- -100 ≤ nums[i] ≤ 100
- nums is sorted in non-decreasing order
Example
- Input
- nums = [1, 1, 2]
- Output
- 2
- Why
- Array becomes [1, 2, _]. Return k = 2 unique elements
Spot the pattern
Which pattern cracks it?
Hints
One at a time