Error message here!

Hide Error message here!


Error message here!


Hide Error message here!


Error message here!



Leetcode 1535. Find the winner of the array game (try your best)

I'm not Xiao Haiwa~~~~ 2022-05-14 15:58:46 阅读数:1 评论数:0 点赞数:0 收藏数:0

Here you are Different An array of integers arr And an integer k .

Each round of the game is in the first two elements of the array ( namely arr[0] and arr[1] ) Carry out between . Compare arr[0] And arr[1] Size , A larger number will win the round and remain in place 0 , The smaller integers are moved to the end of the array . When an integer wins k For consecutive rounds , Game over , This integer is the match's Winner .

Returns the whole number that won the game .

Subject data Guarantee There are winners in the game .

Example 1:

 Input :arr = [2,1,3,5,4,6,7], k 
Copyright statement
In this paper,the author:[I'm not Xiao Haiwa~~~~],Reprint please bring the original link, thank you