mirror of
https://github.com/ShusenTang/LeetCode.git
synced 2026-09-01 21:14:49 +08:00
add 026
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user