← back to unit
Medium
# queues medium
Line of Pairs
The rollercoaster seats two — the line boards in pairs, front two together. 🎢
You get the line (front first). Print each riding pair on its own line as name+name, in boarding order. If someone is left alone at the end, print alone:name last.
Example:
Input: line = ["mia", "leo", "kai", "ana", "bo"]
Output:
mia+leo
kai+ana
alone:bo
Pairs form front-two-at-a-time (mia+leo, then kai+ana), leaving bo alone since the line has an odd count.
💡 need a hint?
q-line-of-pairs.py🔒 given lines are locked — write your code in between
loading...