Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for Digit Stack by gyahun_dash
def digit_stack(commands):
stack = []
total = 0
for command in commands:
if 'PUSH' in command:
stack.append(int(command[-1]))
elif stack != []:
total += stack.pop() if command == 'POP' else stack[-1]
return total
July 8, 2014
Comments: