algorythms
Game Theory & Minimax
LC #877Medium

Stone Game

Game Theory & Minimax

Problem

Similar to Predict the Winner, but with an even number of piles and odd total number of stones. Determine if player 1 can win.

arraydynamic-programmingmathgame-theory

Constraints

  • 2 ≤ piles.length ≤ 500
  • piles.length is even.
  • 1 ≤ piles[i] ≤ 500
  • sum(piles[i]) is odd.

Example

Inputpiles = [5, 3, 4, 5]
Outputtrue
Why

Alice takes 5, Bob takes 5, Alice takes 4, Bob takes 3. Alice 9 > Bob 8.

Hints — reveal one at a time