Can't find what's wrong with this submission


#1
public class Solution 
{
public int removeDuplicates(ArrayList<Integer> a) 
{
    if(a==null)
      return 0;

    if(a.size() <=2)
      return a.size();
      
    int i=0; int j=1;
    int count = 0;
    while (j<a.size())
    {
      if( a.get(i) == a.get(j) && count == 0)
      {
        count = 2;
        j++;
      }
      else
      {
        if(a.get(i)==a.get(j) && count == 2)
          a.remove(j);

        else
        {
          i=j;
          j++;
          count = 0;
        }
      }
    }
    
    return i;
}
}

//Kindly help.


#2

Kindly use equals() instead of == … This might help you