2405. Optimal Partition of String
On This Page
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