Skip to content

Commit fb1b88c

Browse files
authored
Merge pull request #2110 from gnohgnij/0026-remove-duplicates-from-sorted-array
Create: 0026-remove-duplicates-from-sorted-array.java
2 parents b0978b6 + 3c26cb7 commit fb1b88c

File tree

1 file changed

+14
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)