public class Solution {

public int removeDuplicates(int [] nums)

{ int length = nums.length;

//base case

if(length==1)

{ return 1;

}

else

{

for(int i=0;i<length-1;i++)

{

while(nums[i] == nums[i+1])

{

int j = i+1;

for(int k=j+1;k<length;k++)

{

nums[j] = nums[k];

j++;

}

length--;

if(i==length-1)

{

break;

}

}

```
}
return length;
}
```

}

}