Oneline solution

public class Solution {
public int removeDuplicates(ArrayList a) {int i=1;
if(a.size()<=1)return a.size(); else while(i<a.size()) if(a.get(i-1)==a.get(i))a.remove(i); else i++;
return a.size();
Failing for test case [5000 5000 5000] , i think theres some issue with backend

You are comparing object reference instead of object Vaue

use if((int)a.get(i-1)==(int)a.get(i)) , you will correct ans. but tle

Besides, you can’t club multiple LOC and call it a one line solution. lol

Click here to start solving coding interview questions