mirror of
https://github.com/ShusenTang/LeetCode.git
synced 2024-09-02 14:20:01 +00:00
add 026
This commit is contained in:
parent
c5731cf829
commit
8ea58a33c2
11
026-Remove Duplicates from Sorted Array/solution.h
Normal file
11
026-Remove Duplicates from Sorted Array/solution.h
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user