1702. Maximum Binary String After Change

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

Содержание

LeetCode problem 1702

class Solution:
    def maximumBinaryString(self, binary: str) -> str:
        k = binary.find('0')
        if k == -1:
            return binary
        k += binary[k + 1 :].count('0')
        return '1' * k + '0' + '1' * (len(binary) - k - 1)