3175. Find The First Player to win K Games in a Row
A competition consists of
nplayers numbered from0ton - 1.You are given an integer array
skillsof sizenand a positive integerk, whereskills[i]is the skill level of playeri. All integers inskillsare unique.All players are standing in a queue in order from player
0to 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
kgames in a row.Return the initial index of the winning player.
1 | class Solution { |