We’re preparing your current view and syncing the latest data.
Alice and Bob play a game with piles of stones. There are an even number of piles arranged in a row, and each pile has a positive integer number of stones piles[i]. The objective is to determine if Alice, who starts first, will win the game assuming both players play optimally. On each turn, a player chooses a pile from either the start or the end of the row, removes it, and collects the stones. The game ends when there are no piles left. The player with the most stones wins. Return true if Alice wins, otherwise false.
An array of integers piles where piles.length is even and each element represents the number of stones in a pile.
Return a boolean value true if Alice wins, false otherwise.
2 <= piles.length <= 500 piles.length is even 1 <= piles[i] <= 500