Skip to content

Commit

Permalink
Merge pull request #359 from lord-benjamin/patch-4
Browse files Browse the repository at this point in the history
Create 26_Remove_Duplicates_From_Sorted_Array.cpp
  • Loading branch information
strang3-r authored Oct 27, 2022
2 parents 2bce1c2 + c53de6b commit 2b2abee
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions 26_Remove_Duplicates_From_Sorted_Array.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// https://leetcode.com/problems/remove-duplicates-from-sorted-array/

class Solution {
public:
int removeDuplicates(vector<int>& nums) {
for(int i{0}; i<nums.size()-1; ++i){
if(nums.at(i) == nums.at(i+1)){
nums.erase(nums.begin() + i);
i--;
}
}
return nums.size();
}
};

0 comments on commit 2b2abee

Please sign in to comment.