Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Deque and match-case solution in Clear category for Letter Queue by Kverde
from typing import List
from collections import deque
def do_dommand(command, queue):
parsed_command = command.split()
match parsed_command[0]:
case "PUSH":
queue.append(parsed_command[1])
case "POP":
if len(queue) > 0:
queue.popleft()
def letter_queue(commands: List[str]) -> str:
queue = deque()
for command in commands:
do_dommand(command, queue)
return "".join(queue)
Aug. 11, 2022