Trains the technique from
LeetCode 486Predict the WinnerThis 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.
Two auditors clear a row of document bundles. bundles[i] is the page count of the bundle at
position i, and page counts are never negative.
The first auditor moves first and the two then alternate. A move takes the bundle at either end of the row that is left, adds its page count to that auditor's tally, and shortens the row. Play continues until no bundle remains. Both auditors know the whole row from the start and both play as well as possible for their own final tally.
Return true if the first auditor's final tally is at least as large as the second
auditor's, and false otherwise. An equal pair of tallies counts in the first auditor's
favour.
Example 1
With both auditors playing as well as they can, the first ends on 11 pages and the second on 4, so the first is not behind.
Example 2
Best play from both sides ends with the first auditor on 7 pages and the second on 8.
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_auditor_wins(bundles: list[int]) -> bool:public boolean firstAuditorWins(int[] bundles)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.