Skip to content

Commit 694c4cb

Browse files
Merge pull request #3226 from KaiyangYao/main
Create: 0080-remove-duplicates-from-sorted-array-ii.java
2 parents ec2ae50 + 4b39a4a commit 694c4cb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public int removeDuplicates(int[] nums) {
3+
int k = 0;
4+
for (int num: nums) {
5+
if (k < 2 || nums[k-2] != num) {
6+
nums[k++] = num;
7+
}
8+
}
9+
return k;
10+
}
11+
}

0 commit comments

Comments
 (0)