class Solution:
- def partitionLabels(self, s: str) -> List[int]:
- last=[0]*26
- for i in range(len(s)):
- last[ord(s[i])-ord("a")]=i
- res=[]
- start=end=0
- for i in range(len(s)):
- end=max(end,last[ord(s[i])-ord("a")])
- if i==end:
- res.append(end-start+1)
- start=1+end
- return res