Skip to content

Commit 8734b30

Browse files
Created Remove Duplicates from Sorted Array
This file consists of java code for leetcode easy problem Tahanima#24 Remove Duplicates from Sorted Array
1 parent 23dabe3 commit 8734b30

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
class Solution {
2+
public int removeDuplicates(int[] nums) {
3+
int x = nums.length;
4+
int i,j,k,z=0,m=0;
5+
for( i =0; i< x;i++)
6+
{
7+
k = nums[i];
8+
if(nums[i]!= 2147483647){
9+
for( j = i+1; j < x; j++ ){
10+
11+
if(k == nums[j]) {
12+
nums[j] = 2147483647;
13+
}
14+
}
15+
}
16+
}
17+
for(int y =0;y<x;y++){
18+
if(nums[y]!= 2147483647){
19+
nums[z]= nums[y];
20+
z++;
21+
m++;
22+
}
23+
}
24+
25+
return m;
26+
}
27+
}

0 commit comments

Comments
 (0)