Skip to content

Commit 3c26cb7

Browse files
committed
Add Java solution 0026-remove-duplicates-from-sorted-array.java
1 parent 5e52ea6 commit 3c26cb7

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)