n - 1, player i has rating ratings[i], and all ratings are distinct. At the start, the players line up in order of their numbers.
The first two players in line play a game, and the one with the higher rating wins. The winner stays at the front of the line, and the loser goes to the back. Then it repeats.
The champion is the first player to win streak games in a row. Return that player's number.ratings=[3, 8, 5, 1, 9], streak=3 → 1
Player 1 (rating 8) beats player 0, then players 2 and 3: three wins in a row. Player 4 never gets to the table.
ratings=[7, 2, 4], streak=1 → 0
One win is enough, and player 0 takes the very first game.
ratings=[4, 6, 2], streak=1000 → 1
The streak is longer than the number of opponents, so in the end the strongest player, player 1, holds the table for good.
ratings are distinctratings=[3, 8, 5, 1, 9], streak=3
1
Run checks the first 3 tests in your browser. Submit checks all 125 tests on the server, hidden ones included.