2038. Remove Colored Pieces if Both Neighbors are the Same Color

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 2038

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