Skip to content

Commit

Permalink
Sync LeetCode submission - Remove Duplicates from Sorted Array (java)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rupa-Rd committed Aug 8, 2024
1 parent 0a3b5a1 commit ee47e1c
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution {
public int removeDuplicates(int[] nums) {
int i = 0, j = 1;

while(j < nums.length){
if(nums[j] != nums[j - 1]){
nums[++ i] = nums[j];
}
j ++;
}


return i + 1;
}
}

0 comments on commit ee47e1c

Please sign in to comment.