O(n) not good enough?

My code for this problem is explicitly O(n) and it is getting timeouts.
You need to change the original array, so you must have to at least look at each value in the array at least once right?

def removeDuplicates(self, A):
    size = len(A)
    if size < 2:
        return 1
    i = 1
    prev = A[0]
    while i < size:
        if A[i] == prev:
            A.pop(i)
            size -= 1
        else:
            prev = A[i]
            i += 1
    return size

My only guess is that something with the python list methods must be slowing me down and making me miss the O(n) target. Any ideas as to what it could be?

Replying to my own code. The implementation of .pop() in python isn’t always O(n). It is only O(n) in the instance of removing the last element, otherwise it moves all elements in memory u to the end of the list.

Click here to start solving coding interview questions