Python O(n) solution not getting accepted


#1

def removeDuplicates(self, A):
c = 1
m = A[0]
j = 1
if(len(A) <= 2):
return len(A)
while(j < len(A)):
if(A[j] == m):
c += 1
i = j + 1
if(c == 2):
while(i < len(A) and A[i] == m):
A.pop(i)
else:
m = A[j]
c = 1
j += 1
return len(A)


#2

pop operations isnt O(1)