[LeetCode] 926. Flip String to Monotone Increasing

김민우·2023년 1월 17일
0

알고리즘

목록 보기
116/189

- Problem

926. Flip String to Monotone Increasing


- 내 풀이

class Solution:
    def minFlipsMonoIncr(self, s: str) -> int:
        count_zero = count_one = 0

        for i in s:
            if i == '0':
                count_zero += 1
                count_zero = min(count_zero, count_one)
            else:
                count_one += 1
        
        return min(count_zero, count_one)

- 결과

profile
Pay it forward.

0개의 댓글