2038. Remove Colored Pieces if Both Neighbors are the Same Color
On This Page
class Solution:
def winnerOfGame(self, colors: str) -> bool:
a = b = 0
for c, v in groupby(colors):
m = len(list(v)) - 2
if m > 0 and c == 'A':
a += m
elif m > 0 and c == 'B':
b += m
return a > b