Skip to content

Commit 51e2e24

Browse files
Implement RemoveDuplicates class for array processing
1 parent 383ab0c commit 51e2e24

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class RemoveDuplicates {
2+
public int removeDuplicates(int[] nums) {
3+
int i = 0;
4+
int j = 1;
5+
6+
while(j <= nums.length-1){
7+
if(nums[i] != nums[j]){
8+
nums[i+1] = nums[j];
9+
i += 1;
10+
}
11+
j += 1;
12+
}
13+
14+
return i+1;
15+
}
16+
}

0 commit comments

Comments
 (0)