Tap here to switch tabs
Problem
Submissions

Problem: Sum Game

med
30 min
Try to solve the Sum Game problem.

Statement

Alice and Bob play a game with a string num of even length consisting of numerical digits and the character '?'. Alice makes the first move, and the players take alternating turns.

In each turn, a player selects any remaining '?' character in num and replaces it with a digit from 00 to 99. The game ends when no '?' characters remain in num.

Bob wins if the sum of the digits in the first half of num is equal to the sum of the digits in the second half. Alice wins if the two sums are not equal.

Assuming both players play optimally, return true if Alice wins, or false if Bob wins.

Constraints:

  • 2≤2 \leq num.length ≤105\leq 10^5

  • num.length is even.

  • num consists of only digits and '?'.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sum Game

med
30 min
Try to solve the Sum Game problem.

Statement

Alice and Bob play a game with a string num of even length consisting of numerical digits and the character '?'. Alice makes the first move, and the players take alternating turns.

In each turn, a player selects any remaining '?' character in num and replaces it with a digit from 00 to 99. The game ends when no '?' characters remain in num.

Bob wins if the sum of the digits in the first half of num is equal to the sum of the digits in the second half. Alice wins if the two sums are not equal.

Assuming both players play optimally, return true if Alice wins, or false if Bob wins.

Constraints:

  • 2≤2 \leq num.length ≤105\leq 10^5

  • num.length is even.

  • num consists of only digits and '?'.