There are pieces arranged in a row, represented by a string colors where each character is either 'A' or 'B'. Alice and Bob play a game taking alternate turns, with Alice moving first.
On a player’s turn:
Alice may remove a piece colored 'A' only if both of its adjacent neighbors are also colored 'A'. She is not allowed to remove pieces at the ends of the row.
Bob may remove a piece colored 'B' only if both of its adjacent neighbors are also colored 'B'. He is not allowed to remove pieces at the ends of the row.
When a piece is removed, the adjacent pieces shift together to close the gap.
If a player is unable to make a valid move on their turn, that player loses, and the other player wins.
Assuming both players play optimally, return true if Alice wins the game, or false if Bob wins.
Constraints:
colors.length
colors consists of only the letters 'A' and 'B'
There are pieces arranged in a row, represented by a string colors where each character is either 'A' or 'B'. Alice and Bob play a game taking alternate turns, with Alice moving first.
On a player’s turn:
Alice may remove a piece colored 'A' only if both of its adjacent neighbors are also colored 'A'. She is not allowed to remove pieces at the ends of the row.
Bob may remove a piece colored 'B' only if both of its adjacent neighbors are also colored 'B'. He is not allowed to remove pieces at the ends of the row.
When a piece is removed, the adjacent pieces shift together to close the gap.
If a player is unable to make a valid move on their turn, that player loses, and the other player wins.
Assuming both players play optimally, return true if Alice wins the game, or false if Bob wins.
Constraints:
colors.length
colors consists of only the letters 'A' and 'B'