Easy to read and understand Python code


  • 0
    I

    """

    def removeDuplicates(self, A):

        temp = {}
        
        i = 0
        
        while i < len(A):
        
            if A[i] in temp and temp[A[i]] >= 2:
                A.pop(i)
                
            elif A[i] not in temp:
                temp[A[i]] = 1
                i += 1
            else:
                temp[A[i]] += 1
                i += 1
            
        return len(A)
    

    """


Log in to reply
 

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