Tournament Rounds by Rank
You are given an array ranks representing players in tournament order. A smaller number means a stronger rank.
In each round, adjacent players compete: indices 0 and 1, indices 2 and 3, and so on. The player with the smaller rank number advances to the next round. If a round has an odd number of players, the last player advances automatically.
Return the list of rounds after each elimination round. Each inner array should contain the ranks that advanced from that round, in order. Continue until one player remains.
Complete the function simulateTournamentRounds in the editor.
simulateTournamentRounds has the following parameter:
int ranks[]: player ranks in the initial bracket order
Returns
int[][]: the advancing ranks after each round
1Example 1
2Example 2
Constraints
Limits and guarantees your solution can rely on.
- Rank values are distinct.
- A smaller rank number represents a stronger player.
- If a round has an odd number of players, the last player advances automatically.