877. Stone Game

Practice Stone Game for free on NudgeCode: Medium, Dynamic Programming pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Piles of stones stand in a row with sizes piles. Alice and Bob alternate turns, Alice first; on each turn a player takes the whole pile from either the left end or the right end of the row. When no piles remain, whoever holds more stones wins. If both play as well as possible, return whether Alice wins.

Example

piles = [5,3,4,5]  ->  true
piles = [3,7,2,3]  ->  true

Constraints