Stone Game III

Hard · Dynamic Programming · about 25 minutes

Asked at Amazon, Google, Microsoft.

Stones in a row have values stoneValue. Alice and Bob alternate (Alice first); on a turn a player takes 1, 2 or 3 stones from the front, adding their values to their score. Both play optimally. Return "Alice", "Bob" or "Tie".

Related guides