Remove Duplicates from Sorted Array — C# Coding Problem
Difficulty: easy | Category: array
Problem Description
Given an integer array `nums` sorted in **non-decreasing order**, remove the duplicates **in-place** such that each unique element appears only once. Return the number `k` — the count of unique elements. The first `k` elements of `nums` should hold the unique values in order. **Constraints:** - `1 <= nums.length <= 3 × 10⁴` - `-100 <= nums[i] <= 100` - `nums` is sorted in non-decreasing order.
Examples
Example 1
Input: nums = [1,1,2]
Output: 2
Explanation: The first 2 elements are [1,2]. Return k=2.
Example 2
Input: nums = [0,0,1,1,1,2,2,3,3,4]
Output: 5
Explanation: Return k=5.