Simple python Solution


  • 0
    L
    class Solution:
        # @param a list of integers
        # @return an integer
        def removeDuplicates(self, A):
            if len(A) == 0:
                return 0
            temp = A[0]
            n = 1
            for num in A[1:]:
                if num != temp:
                    temp = num
                    A[n] = num
                    n += 1
            A = A[:n]
            return n

Log in to reply
 

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