TLE at submission>?

all of those who are using erase() at every step will get TLE at submission
remember erase function is heavy use it wisely :wink:

A.erase (unique(A.begin(),A.end()),A.end());
return A.size()
works fine, don’t use erase() inside loop it’ll give TLE.

Click here to start solving coding interview questions