Seems like Issue with Inteview Bit execution


#1
public int removeElement(ArrayList<Integer> arr, int b) {
    
   int count=0;
   int i=0,j=0;
   if(arr.size()==0)
       return 0;
   if(arr.size()==1)
   {
       if(arr.get(i)==b)
           return 0;
       else
           return 1;
   }
   while(i<arr.size() && j<arr.size() )
   {
       if(arr.get(i)==b)
       {
          if(arr.get(j)!=b)
          {
              arr.set(i,arr.get(j));
              arr.set(j,b);
              //arr.remove(j);
              i++;
              j++;
              count++;
          }
          else
          {
              j++;
          }
        
       // arr.remove(i);
       // i++;
       // count++;
       }
      else {
          i++;
      }
   }
  // System.out.println(count);
   return count;

}

If i return count, the output prints as 0 0 0 0 0 0 0
if i return count-1, the output is getting printed fine expect for the last element. Seems to be an issue from Interview bit execution.