Tap here to switch tabs
Problem
Submissions

Problem: The Earliest and Latest Rounds Where Players Compete

Try to solve the The Earliest and Latest Rounds Where Players Compete problem.

Statement

There is a tournament with n players numbered from 11 to n standing in a single row in increasing order of their numbers.

The tournament consists of multiple rounds. In each round:

  • Players compete in pairs based on their positions in the row. The ithi^{th} player from the front competes against the ithi^{th} player from the back (the player at index ii faces the player at index k−i+1k - i + 1, where kk is the total number of remaining players in the current round).

  • If the number of players kk is odd, the middle player advances directly to the next round without playing a match.

  • The winners of each match, along with any player who advanced directly, move on to the next round while preserving their relative order.

Two specific players, firstPlayer and secondPlayer, are the best players in the tournament. Each of them is guaranteed to win every match against any opponent other than each other. When firstPlayer and secondPlayer compete against each other, the tournament ends.

Return an array of two integers representing the earliest round number and the latest round number in which firstPlayer and secondPlayer can face each other. Round numbers start at 11.

Constraints:

  • 2≤2 \leq n ≤28\leq 28

  • 1≤1 \leq firstPlayer << secondPlayer ≤\leq n

⋮
Tap here to switch tabs
Problem
Submissions

Problem: The Earliest and Latest Rounds Where Players Compete

Try to solve the The Earliest and Latest Rounds Where Players Compete problem.

Statement

There is a tournament with n players numbered from 11 to n standing in a single row in increasing order of their numbers.

The tournament consists of multiple rounds. In each round:

  • Players compete in pairs based on their positions in the row. The ithi^{th} player from the front competes against the ithi^{th} player from the back (the player at index ii faces the player at index k−i+1k - i + 1, where kk is the total number of remaining players in the current round).

  • If the number of players kk is odd, the middle player advances directly to the next round without playing a match.

  • The winners of each match, along with any player who advanced directly, move on to the next round while preserving their relative order.

Two specific players, firstPlayer and secondPlayer, are the best players in the tournament. Each of them is guaranteed to win every match against any opponent other than each other. When firstPlayer and secondPlayer compete against each other, the tournament ends.

Return an array of two integers representing the earliest round number and the latest round number in which firstPlayer and secondPlayer can face each other. Round numbers start at 11.

Constraints:

  • 2≤2 \leq n ≤28\leq 28

  • 1≤1 \leq firstPlayer << secondPlayer ≤\leq n