Asked 1 month ago
1
38
Given an integer array nums
 sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. Then return the number of unique elements in nums
.
Consider the number of unique elements of nums
 to be k
, to get accepted, you need to do the following things:
nums
 such that the first k
 elements of nums
 contain the unique elements in the order they were present in nums
 initially. The remaining elements of nums
 are not important as well as the size of nums
.k
.Custom Judge:
The judge will test your solution with the following code:
If all assertions pass, then your solution will be accepted.
Example 1:
Example 2:
Constraints:
1 <= nums.length <= 3 * 10
4
-100 <= nums[i] <= 100
nums
 is sorted in non-decreasing order.1
1
0
This is my accepted answer from leetcode:
Hope it helps 😃