Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Digit Stack by UFO665
def digit_stack(commands):
res = 0
stack = []
for cmd in commands:
if "PUSH" in cmd:
stack.append(int(cmd.split()[-1]))
elif cmd == "POP" and stack:
res += stack.pop()
elif stack:
res += stack[-1]
return res
Dec. 10, 2015