← back to unit
Challenge
# queues advanced
Card War Line
Everyone holds one numbered card. The front TWO battle: the higher card wins, the winner rejoins the back, the loser is out. ⚔️
You get the cards (all different, front first). Battles continue until one card remains. Print it.
Example:
Input: cards = [3, 7, 1, 9, 4]
Output: 9
3 vs 7 → 7 wins and rejoins the back. 1 vs 9 → 9 wins and rejoins. The winners keep battling until only the biggest card, 9, remains.
💡 need a hint?
q-card-war-line.py🔒 given lines are locked — write your code in between
loading...