Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
dict + lambda solution in Clear category for Letter Queue by kdim
from typing import List
def letter_queue(commands: List[str]) -> str:
q = {
'PUSH': lambda x: queue + x,
'POP': lambda x: queue[1:]
}
queue = []
for i in commands:
c, p = list(i.split())[0], list(i.split())[1:]
queue = q[c](p)
return ''.join(queue)
Jan. 27, 2021
Comments: