Got Partial Marks But it shows TLE

Here is my code:

def removeDuplicates(self, A):
i=0
count=0
if len(A)==1:
return 1
while i<len(A)-1:
if A[i]==A[i+1]:
del A[i]
else:
count +=1
i+=1
return count+1

since you are deleting so I think it is a O(n) operation.
So overall your solution becomes O(n2)…that will give u a tle

Click here to start solving coding interview questions