1758. Minimum Changes To Make Alternating Binary String

Updated: 2024-03-12
1 min read
[]

On This Page

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)