# 2038. Remove Colored Pieces if Both Neighbors are the Same Color
###### tags: `Leetcode` `Medium` `Math`
Link: https://leetcode.com/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/description/
## 思路
思路参考[这里](https://leetcode.com/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/solutions/1524153/c-python-java-count-aaa-and-bbb/)
Alice只能remove 'AAA' 中间的那个'A'
Bob只能remove 'BBB' 中间的那个'B'
两者互不影响
所以只要看字串里有多少个'AAA' 多少个'BBB'
如果'AAA'多 那么Alice赢 'BBB'多 Bob赢
## Code
```python=
class Solution:
def winnerOfGame(self, colors: str) -> bool:
a = b = 0
for i in range(1, len(colors)-1):
if colors[i-1]==colors[i]==colors[i+1]:
if colors[i]=='A': a+=1
else: b+=1
return a>b
```