Game Winner

Company: jpmc_9aug

Difficulty: medium

Problem Statement

Game Winner Problem Description A chess tournament has n players numbered 1 to n . Player i has a potential potential[i] , and all potentials are different. At the start, the players stand in a queue in order 1, 2, ..., n . The tournament is a sequence of games: The first two players in the queue play a game. The player with the higher potential wins. The winner stays at the front of the queue, and the loser goes to the back of the queue. The tournament ends as soon as some player has won k games in a row . Given the potentials and the deciding factor k , find the potential of the player who wins the tournament. Function Description Complete the function getPotentialOfWinner . It has the following parameters: potential : an array of n integers, the potentials of players 1 to n in their starting queue order. k : a 64-bit integer, the number of consecutive wins needed. It returns an integer: the potential of the winning player. Input Format Read from standard input. n potential[1] potent