All problems
0301MediumArrayMathDynamic ProgrammingRecursionMinimaxGame TheoryZero-Sum Game

Bundle Claim Duel

Tracked in this browser only
Write code

Trains the technique from

LeetCode 486Predict the Winner

This 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.

Examples

Example 1

Input
bundles = [3,9,1,2]
Output
true

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

Input
bundles = [4,8,3]
Output
false

Best play from both sides ends with the first auditor on 7 pages and the second on 8.

Constraints

  • 1 <= bundles.length <= 20
  • 0 <= bundles[i] <= 10^7

The signature

The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.

Python
def first_auditor_wins(bundles: list[int]) -> bool:
Java
public boolean firstAuditorWins(int[] bundles)
September 7
Apply