Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. class Solution {
  2. // 26. Remove Duplicates from Sorted Array
  3. public int removeDuplicates(int[] nums) {
  4. if (nums.length == 0)
  5. return 0;
  6.  
  7. int i = 0;
  8. for (int j = 1; j < nums.length; j++) {
  9. if (nums[j] != nums[i]) {
  10. i++;
  11. nums[i] = nums[j];
  12. }
  13. }
  14. return i + 1;
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement