8000 Create 0026_Remove Duplicates from Sorted Array.java · berkayzaimdev/LeetCode-Java@e74bf52 · GitHub
[go: up one dir, main page]

Skip to content

Commit e74bf52

Browse files
Create 0026_Remove Duplicates from Sorted Array.java
1 parent f8a02fa commit e74bf52

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+
class Solution
2+
{
3+
public int removeDuplicates(int[] nums)
4+
{
5+
if(nums.length==0) return 0;
6+
int k=1;
7+
for(int i=0;i<nums.length-1;i++)
8+
{
9+
if(nums[i]<nums[i+1]) nums[k++]=nums[i+1];
10+
}
11+
return k;
12+
}
13+
}

0 commit comments

Comments
 (0)
0