Skip to content

Commit e8d1b4f

Browse files
Create 0026-Remove-Duplicates-from-Sorted-Array.cpp
C++
1 parent 324cd74 commit e8d1b4f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public:
3+
int removeDuplicates(vector<int>& nums) {
4+
int left = 1;
5+
6+
for(int right = 1; right < nums.size(); right++){
7+
if(nums[right] != nums[right - 1]){
8+
nums[left] = nums[right];
9+
left++;
10+
}
11+
}
12+
13+
return left;
14+
}
15+
};

0 commit comments

Comments
 (0)