Dashboard
LC #877
Stone Game
Pattern · ?
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.
Constraints
- 2 ≤ piles.length ≤ 500
- piles.length is even.
- 1 ≤ piles[i] ≤ 500
- sum(piles[i]) is odd.
Example
- Input
- piles = [5, 3, 4, 5]
- Output
- true
- Why
- Alice takes 5, Bob takes 5, Alice takes 4, Bob takes 3. Alice 9 > Bob 8.
Spot the pattern
Which pattern cracks it?
Hints
One at a time