Here is my O(n) time complexity and O(1) space complexity solution.
def removeDuplicates(self, A): if len(A) < 1: return None seed = A c = 1 for i in range(len(A)): if A[i] != seed: A[c] = A[i] seed = A[i] c += 1 return A[:c]
The following is the error i’m getting
Traceback (most recent call last):
File “main.py”, line 172, in
cnt -= 1
TypeError: unsupported operand type(s) for -=: ‘list’ and ‘int’
I have not used any variable “cnt”, it error from their side I guess. If anybody knows how to solve it, it would be appreciated. Thankyou!