Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d0d22a6

Browse files
authored
Create: 0026-remove-duplicates-from-sorted-array.cs
1 parent dbae42b commit d0d22a6

File tree

1 file changed

+13
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)