2405. Optimal Partition of String

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

Содержание

LeetCode problem 2405

class Solution:
    def partitionString(self, s: str) -> int:
        res, v = 1, 0
        for c in s:
            i = ord(c) - ord('a')
            if (v >> i) & 1:
                v = 0
                res += 1
            v |= 1 << i
        return res