Skip to content

Commit 19474b6

Browse files
committed
Time: 1 ms (81.03%) | Memory: 44.5 MB (72.77%) - LeetSync
1 parent 3e86f61 commit 19474b6

File tree

1 file changed

+17
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)