β back to unit
Easy
# queues easy
The Double-Door Bus
This fancy bus has doors at BOTH ends β the conductor's list says which door each kid uses. π
You get commands β front:name or back:name. Board everyone with a deque (appendleft and append) and print the bus from front to back, comma-separated.
Example:
Input: commands = ["back:mia", "front:leo", "back:kai"]
Output: leo,mia,kai
Mia boards at the back first ([mia]), leo boards at the front ([leo, mia]), then kai boards at the back ([leo, mia, kai]).
π‘ need a hint?
q-double-door-bus.pyπ given lines are locked β write your code in between
loading...