```
public class Solution {
public int removeDuplicates(int[] nums) {
if(nums.length == 1){
return 1;
}
int len = nums.length;
int i = 0;
int index = 0;
while(i != nums.length){
index = nums[i];
i++;
while(true){
if(i == nums.length){
break;
}
if(nums[i] == index){
len--;
i++;
}else{
i++;
break;
}
}
System.out.println(i);
}
return len;
}
}
```

For

input `[1, 2, 2]`

it returns `[1, 2, 2]`

instead of ```[1, 2]`` but when I hand run my algorithm it gives the proper length, which is 2?