Partition labels by character occurrence

Write codeMedium20 minAmazon style

Your task

You are given a string s of lowercase English letters. Partition it into as many contiguous parts as possible so that each letter appears in at most one part. Return a list of the sizes of these parts, in left-to-right order. The string has length between 1 and 500.

Examples

partition_labels(s: str) -> list[int]
Example 1
Inputpartition_labels("ababcbacadefegdehijhklij")
Output[9, 7, 8]