python just pass it without checking the boundary


  • 1
    1
    def calPoints(self, ops):
    
        ops1=[]
        for i in range(len(ops)):
            if ops[i]=='D':ops1.append(ops1[-1]*2)
            elif ops[i]=='+':ops1.append(ops1[-1]+ops1[-2])                
            elif ops[i]=='C':
                ops1.pop()
            else:
                ops1.append(int(ops[i]))
        return sum(ops1)

Log in to reply
 

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