Company: jpmc_9aug
Difficulty: medium
Game Winner Problem Description A chess tournament has n participants numbered 1 to n, each with a unique potential value, potential[i] . Initially, participants queue in order from 1 to n. In each game, the first two participants in the queue compete. The participant with the higher potential wins. The winner remains at the front of the queue, while the loser goes to the end. The tournament continues until a player wins k consecutive games. Given the potential of the participants and the deciding factor k , find the potential of the winning player. Examples Example 1: Input: Consider n = 4 participants have potential = [3, 2, 1, 4], and k = 2. Explanation: Initial position of participants: [1, 2, 3, 4]. Participants 1 and 2 compete. Their potentials are 3 and 2. Player 1 wins due to the higher potential. Player 1 stays at the front of the queue, and player 2 moves to the back. Now their positions are [1, 3, 4, 2]. Participants 1 and 3 compete. Their potentials are 3 and 1. 1 wins a se