题目
代码
class Solution:
def partitionLabels(self, S):
"""
:type S: str
:rtype: List[int]
"""
tmp_dict = {c:i for i, c in enumerate(S)}
res_list = []
j = -1
startIndex = 0
for i, v in enumerate(S):
j = max(j, tmp_dict[v])
if i == j:
res_list.append(j - startIndex + 1)
startIndex = j + 1
return res_list