Why the following code can run on my local computer and can't get accepted on the OJ


  • 0
    D
    class Solution:
    # @param A a list of integers
    # @return an integer
    def removeDuplicates(self, A): 
        j=0 
        l=len(A)
        count=1
        for i in range(1,l):
            if A[i]==A[j]:
                A[j+1]=A[i]
                count=count+1
            else:
                if count>=2:
                    j=j+2
                else:
                    j=j+1
                A[j]=A[i]
                count=1
        if count>=2:
            return j+2 
        else:
            return j+1

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.