Skip to content

Commit 045a898

Browse files
Time: 1 ms (42.92%), Space: 40.3 MB (87.45%) - LeetHub
1 parent 6c1a1df commit 045a898

File tree

1 file changed

+16
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)