mirror of
https://github.com/ShusenTang/LeetCode.git
synced 2024-09-02 14:20:01 +00:00
12 lines
282 B
C++
12 lines
282 B
C++
class Solution {
|
|
public:
|
|
int removeDuplicates(vector<int>& nums) {
|
|
if(nums.empty()) return 0;
|
|
int count = 0;
|
|
for(int i = 1; i < nums.size(); i++){
|
|
if(nums[i] != nums[count]) nums[++count] = nums[i];
|
|
}
|
|
return count+1;
|
|
}
|
|
};
|