Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- knakul853
- **/
- class Solution {
- public:
- int removeDuplicates(vector<int>& nums) {
- if(nums.empty()) return 0;
- int n = (int)nums.size();
- int l = 0;
- for( int i = 1; i < n; i++ )
- {
- if(nums[l] != nums[i])
- {
- nums[++l] = nums[i];
- }
- }
- return l+1;
- }
- };
Add Comment
Please, Sign In to add comment