We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents ec2ae50 + 4b39a4a commit 694c4cbCopy full SHA for 694c4cb
java/0080-remove-duplicates-from-sorted-array-ii.java
@@ -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