class Solution: # @param a list of integers # @return an integer def removeDuplicates(self, A): if A == : return(0) count = 1; for i in range(1,len(A)): if A[i] != A[i-1]: count += 1 return(count)
You didn't remove the duplicates from your array.
e.g. if the input is
you need to make it like:
1,2,2 with count = 2 (since we can't really delete elements from array, just leave the last elements there but somewhat treat the valid array size as 2)