-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path26.cpp
More file actions
25 lines (25 loc) · 668 Bytes
/
26.cpp
File metadata and controls
25 lines (25 loc) · 668 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class Solution {
public:
int removeDuplicates(vector<int>& nums) {
int leng = nums.size();
int explore = 0, end = 0;
while (explore < leng) {
if (explore == leng - 1) {
break;
}
else {
//explore < leng - 1
if (nums[explore] == nums[explore + 1]) {
explore++;
}
else {
//nums[explore] != nums[explore + 1]
explore++;
end++;
nums[end] = nums[explore];
}
}
}
return end + 1;
}
};