Uber 店面

直接上题

You will be given array of size N with integers numbered 1 to N in random order and a number k.
for eg. arr = 2 1 3 4 5, k = 2

Let these players are standing in a queue in a given order, first two players will play a game then whose value is greater will win and the lost one will go to end of a queue.
Whoever player will win consecutive k games is the winner of game.

In the above example,
first match b/w : 2 & 1
second match b/w : 2 & 3
third match b/w : 3 & 4
fourth match b/w : 4 & 5
fifth match b/w : 5 & 1

5 won 2 matches consecutively: 5 is winner

Solution should be O(n) in time and 0(1) in space. arr is immutable