Guest User

Untitled

a guest
Feb 17th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. class removeDuplicate {
  2. public int removeDuplicates(int[] nums) {
  3. if(nums.length==0) return 0;
  4. if(nums.length==1) return 1;
  5. int index = 1;
  6. for(int i =1; i< nums.length;i++){
  7. if(nums[index-1]!= nums[i]){
  8. index++;
  9. nums[index-1] = nums[i];
  10. }
  11. }
  12. return index;
  13. }
  14. }
Add Comment
Please, Sign In to add comment