1422. Maximum Score After Splitting a String

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

Содержание

LeetCode problem 1422

class Solution:
    def maxScore(self, s: str) -> int:
        res = t = (s[0] == '0') + s[1:].count('1')
        for i in range(1, len(s) - 1):
            t += 1 if s[i] == '0' else -1
            res = max(res, t)
        return res