Greedy Algorithms - Partition Labels
Given the following code for partitioning labels, what is the returned list when the input string is
"eccbbbbdec"?
def partitionLabels(s):
last = [0] * 26
for i, c in enumerate(s):
last[ord(c) - ord('a')] = i
res = []
start = 0
end = 0
for i, c in enumerate(s):
end = max(end, last[ord(c) - ord('a')])
if i == end:
res.append(end - start + 1)
start = i + 1
return res
