1758. Minimum Changes To Make Alternating Binary String

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

Содержание

LeetCode problem 1758

class Solution:
    def minOperations(self, s: str) -> int:
        cnt = sum(c != '01'[i & 1] for i, c in enumerate(s))
        return min(cnt, len(s) - cnt)