3175. Find The First Player to win K Games in a Row
A competition consists of
n
players numbered from0
ton - 1
.You are given an integer array
skills
of sizen
and a positive integerk
, whereskills[i]
is the skill level of playeri
. All integers inskills
are unique.All players are standing in a queue in order from player
0
to playern - 1
.The competition process is as follows:
- The first two players in the queue play a game, and the player with the higher skill level wins.
- After the game, the winner stays at the beginning of the queue, and the loser goes to the end of it.
The winner of the competition is the first player who wins
k
games in a row.Return the initial index of the winning player.
1 | class Solution { |