Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- // 26. Remove Duplicates from Sorted Array
- public int removeDuplicates(int[] nums) {
- if (nums.length == 0)
- return 0;
- int i = 0;
- for (int j = 1; j < nums.length; j++) {
- if (nums[j] != nums[i]) {
- i++;
- nums[i] = nums[j];
- }
- }
- return i + 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement