Please tell me what my code will give on dryrun on input=[5000,5000,5000]


#1

public class Solution {
public int removeDuplicates(ArrayList a) {
if(a.size()<=1)
return a.size();
int len=a.size();
int i=0;
int k=0;
int count=0;
while(i<len)
{
int j=i+1;
while((j<len)&&(a.get(i)==a.get(j)))
{
j++;
}
//System.out.println(“j is”+j);
if(j==len)
{
int tmp=a.get(i);
a.set(k,tmp);
k++;
count++;
//System.out.print(k);
return count;
}
else
{
int tmp=a.get(i);
a.set(k,tmp);
i=j;
k++;
count++;
}
}
return count;
}
}


#2

Use .equal() instead of == because == not work for large input.It is Integer Class not ordinary primative int .We should use equal() to compare two class objects.