Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class removeDuplicate {
- public int removeDuplicates(int[] nums) {
- if(nums.length==0) return 0;
- if(nums.length==1) return 1;
- int index = 1;
- for(int i =1; i< nums.length;i++){
- if(nums[index-1]!= nums[i]){
- index++;
- nums[index-1] = nums[i];
- }
- }
- return index;
- }
- }
Add Comment
Please, Sign In to add comment