6. Cards Game от Exercise: Lists / Arrays Advanced - Java
Здравейте
Имам проблем с една задача. Условието на задачата е:
6. Cards Game
You will be given two hands of cards, which will be integer numbers. Assume that you have two players. You have to find out the winning deck and respectively the winner.
You start from the beginning of both hands. Compare the cards from the first deck to the cards from the second deck. The player, who has bigger card, takes both cards and puts them at the back of his hand - the second player's card is last, and the first person's card (the winning one) is before it (second to last) and the player with smaller card must remove the card from his deck. If both players' cards have the same values - no one wins, and the two cards must be removed from the decks. The game is over when one of the decks is left without any cards. You have to print the winner on the console and the sum of the left cards: "Player {one/two} wins! Sum: {sum}".
Examples
Input |
Output |
20 30 40 50 10 20 30 40 |
First player wins! Sum: 240 |
10 20 30 40 50 50 40 30 30 10 |
Second player wins! Sum: 50 |
Mоето решение
Съдията ми дава:
75 / 100 | Памет: 1.11 MB Време: 0.918 s |
Тест №3 (Недостатъчно време)
Използвано време: 0.918 s
Използвана памет: 0.90 MB
Ако правилно съм разбрала отговора е верен но не се включва във времето. Ще бъда благодарна ако някой погледне кода и ми каже къде е проблема.
Благодаря