← back to unit
Medium
# queues medium
The Empty Counter
Sometimes the server calls NEXT! at an empty counter. Awkward. 😶
You get commands (join:name / serve) — but serves may hit an empty line. For each empty serve, print nobody here on its own line. At the end print the number still waiting.
Example:
Input: commands = ["serve", "join:mia", "serve", "serve"]
Output:
nobody here
nobody here
0
The first serve hits an empty line (nobody here). mia joins, and serving her empties the line again, so the third serve also finds nobody — leaving 0 waiting at the end.
💡 need a hint?
q-empty-counter.py🔒 given lines are locked — write your code in between
loading...