Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. class Solution {
  2. public:
  3. int removeDuplicates(vector<int>& nums) {
  4. int length = nums.size();
  5. int index = 1;
  6.  
  7. if (length == 0)
  8. return 0;
  9.  
  10. for(int i=1; i<length; i++) {
  11. if (nums[i] != nums[i-1])
  12. nums[index++] = nums[i];
  13. }
  14.  
  15. return index;
  16. }
  17. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement