Skip to content

Commit 72f574a

Browse files
authored
Merge pull request gzc426#34 from ZreoWdd/master
1
2 parents 2bf7794 + bd8a675 commit 72f574a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

2019.11.25-leetcode80/黎明初醒.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
```
2+
class Solution {
3+
public int removeDuplicates(int[] nums) {
4+
if(nums.length==0){
5+
return 0;
6+
}
7+
int count = 0;
8+
int j = 0;
9+
for(int i=1;i<nums.length;i++){
10+
if(nums[j]==nums[i]){
11+
count++;
12+
13+
if(count<2) {
14+
nums[++j]=nums[i];
15+
}
16+
}else{
17+
nums[++j] = nums[i];
18+
count = 0;
19+
}
20+
}
21+
return j+1;
22+
}
23+
}
24+
```
25+
//i为快指针,j为慢指针。

0 commit comments

Comments
 (0)