Given an array of distinct integers arr and an integer k.
A game is played between the first two elements of arr. In each round:
The larger of arr[0] and arr[1] wins and remains at index
The smaller element loses and is moved to the end of arr.
The game continues until an element achieves k consecutive round victories.
Return the integer that wins the game.
Note: It is guaranteed that a winner exists.
Constraints:
arr.length
arr[i]
arr contains distinct integers.
k
Given an array of distinct integers arr and an integer k.
A game is played between the first two elements of arr. In each round:
The larger of arr[0] and arr[1] wins and remains at index
The smaller element loses and is moved to the end of arr.
The game continues until an element achieves k consecutive round victories.
Return the integer that wins the game.
Note: It is guaranteed that a winner exists.
Constraints:
arr.length
arr[i]
arr contains distinct integers.
k