Practice Remove Colored Pieces if Both Neighbors are the Same Color
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Remove Colored Pieces if Both Neighbors are the Same Color
Problem Statement
Alice and Bob alternate removals, with Alice first. Alice may remove an A only when both immediate neighbors are A; Bob has the same rule for B. Endpoint pieces cannot be removed. A player unable to move loses. Return whether Alice wins when both play optimally.
Source: Remove Colored Pieces if Both Neighbors are the Same Color on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
colors = "AAABABB"
true
# Example 2
colors = "AA"
false
# Example 3
colors = "ABBBBBBBAAA"
false
Constraints
Related LeetCode Problems
Practice more problems similar to Remove Colored Pieces if Both Neighbors are the Same Color.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.