Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Single ended solution in Clear category for Digit Stack by veky
def digit_stack(commands):
stack, digitsum = [], 0
for command in commands:
if command.startswith("PUSH"):
stack.append(int(command[-1]))
elif stack:
digitsum += stack[-1]
if command == "POP":
stack.pop()
return digitsum
July 2, 2014
Comments: