It should be right, but Runtime Error??


  • 0
    Z
    class Solution:
            # @param a list of integers
            # @return an integer
        def removeDuplicates(self,A):
            if A == []: 
            	index = 0 
            else: 
            	index = 1 
            	for i in range(1,len(A)): 
            		if A[i] != A[i-1]:
            		    A[index] = A[i]
            			index += 1
            for i in range(len(A)- index):
            	A.pop()
            
            return index
    

    Runtime Error Message: Line 12: IndentationError: unexpected indent
    Last executed input: []
    Could anyone please help me firgure out what's wrong? The code was all right running on my PC... :(


  • 1
    V

    To make it work, you have the remove the last for loop.


Log in to reply
 

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