Two Pointers
LC #26Easy
Remove Duplicates from Sorted Array
Two Pointers
AmazonMicrosoftGoogleProblem
Remove duplicates from a sorted array in-place and return the count of unique elements.
arraytwo-pointers
Constraints
- ›1 ≤ n ≤ 3 × 10⁴
- ›-100 ≤ nums[i] ≤ 100
- ›nums is sorted in non-decreasing order
Example
Input
nums = [1, 1, 2]Output
2Why
Array becomes [1, 2, _]. Return k = 2 unique elements