#763

Partition Labels

pupil · 420 · lc medium +25 · verified · 81.8% accepted · 11,204 likes · top 93%

Description

Given a string s, split it into the maximum number of parts such that no character appears in more than one part. The parts must concatenate back to s in order.

Return a list of the sizes of the parts.

Example 1:

Input: s = "ababcbacadefegdehijhklij"
Output: [9,7,8]
Explanation:
The partition is "ababcbaca", "defegde", "hijhklij".
This is a partition so that each letter appears in at most one part.
A partition like "ababcbacadefegde", "hijhklij" is incorrect, because it splits s into less parts.

Example 2:

Input: s = "eccbbbbdec"
Output: [10]

Code

1
2
3