Trains the technique from
LeetCode 1535Find the Winner of an Array GameThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A club runs a ladder on its practice lane. ratings lists the players waiting in one queue from front to back, so ratings[0] is at the very front, and every rating in the list is different.
A round is played like this: the two players at the front of the queue face each other, the one with the higher rating stays where it is at the front, and the other walks to the very back of the queue. Rounds are played one after another until some player has won k rounds in a row, counting only rounds played since that player last arrived at the front. That player takes the ladder.
Return the rating of the player who takes the ladder.
Example 1
Round one is 1 against 4, so 4 stays at the front and 1 goes to the back, leaving the queue 4, 2, 9, 1. Round two is 4 against 2, so 4 wins again. That is two rounds in a row for 4, which is what `k` asks for.
Example 2
3 beats 1 and 2, then loses to 9 in the third round. From that round on 9 stands at the front and wins every round that follows, so its streak passes seven.
Example 3
The queue holds only two players. 2 beats 1 in the first round, and one win in a row is all `k` asks for.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def ladder_winner(ratings: list[int], k: int) -> int:public int ladderWinner(int[] ratings, int k)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.