cards, each with a different number. You deal them in order onto two piles, left and right:
- the first card goes on the left pile, the second on the right pile;
- each following card goes on the left pile if the number on top of the left pile is **greater** than the number on top of the right pile; otherwise it goes on the right pile.
Once every card is dealt, list the left pile from bottom to top, followed by the right pile, also from bottom to top. Return that list.cards=[6, 9, 4, 7] → [6, 7, 9, 4]
6 goes to the left pile and 9 to the right. The tops are 6 and 9; the left one is not larger, so 4 goes right. Now the tops are 6 and 4; the left one is larger, so 7 goes left. Left pile [6, 7], right pile [9, 4].
cards=[10, 3, 8, 6, 5] → [10, 8, 6, 5, 3]
The left pile's top stays larger than the right pile's top the whole time, so every card after the second goes left: [10, 8, 6, 5] and [3].
cards=[1, 2, 3] → [1, 2, 3]
cards are distinctcards=[6, 9, 4, 7]
[6, 7, 9, 4]
Run checks the first 3 tests in your browser. Submit checks all 102 tests on the server, hidden ones included.