What's wrong with this solution


  • 0
    M
    class Solution:
    # @param a list of integers
    # @return an integer
    def removeDuplicates(self, A):
        old_length = len(A)
        start = 0
    
        while start < old_length:
            next = start+1
            while next < old_length:
                if A[next] == A[start]:
                    del A[next]
                    old_length-=1
                else:
                    next+=1
            start+=1
        return A

  • 0
    U

    Your code changed the size of A. The OJ rejects that. You are required to return the size of unique numbers without modification of A's size.


Log in to reply
 

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