Trains the technique from
LeetCode 877Stone 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 closing auction lines up piles sealed bins on a shelf, left to right. Bin i contains piles[i] tokens.
Iris claims a bin first, then Odell, and they keep alternating. A claim always takes one whole bin from either the far left or the far right of whatever is still on the shelf, and every token inside a claimed bin is credited to whoever claimed it. The duel ends when the shelf is bare, and by then every bin has been claimed.
Each of them plays for the largest personal token total they can force, whatever the other one does.
Return true if Iris finishes with a strictly larger token total than Odell, and false otherwise.
Example 1
Iris ends the duel with a strictly larger token total than Odell, so true is returned.
Example 2
Iris claims the right-hand bin for 2 tokens, Odell is left with the bin holding 1, and 2 beats 1.
Example 3
Iris finishes ahead of Odell over the four claims.
Example 4
Iris finishes with a larger total than Odell across the six claims, so true is returned.
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 first_bidder_wins(bins: list[int]) -> bool:public boolean firstBidderWins(int[] bins)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.