Why does the code not pass the test case [5000, 5000, 5000] but passes [50, 50, 50]


#1

public class Solution {
public int removeDuplicates(ArrayList a) {
int l = a.size();
int i=0, j=0;
while(j<l){
if(a.get(i)!=a.get(j)){
a.set(i+1, a.get(j));
i++;
}
j++;
}
return i+1;
}
}


#2

In java integers more than 128 are not cached so you have to do object comparision instread of ==


#3

Thanks for this information.