LeetcodeFull List20002405. Optimal Partition of StringOn this page2405. Optimal Partition of StringPython Greedy class Solution: def partitionString(self, s: str) -> int: if len(s) == 1: return 1 partition = set() counter = 1 for letter in s: if letter in partition: partition = set() counter += 1 partition.add(letter) return counter