Partition Labels
MediumP2Coding
Split the string s into as many parts as possible so that each letter appears in at most one part. Return the sizes of the parts, in order. The parts, concatenated, must give back s.
Example 1
- Input
- s = "ababcbacadefegdehijhklij"
- Output
- [9,7,8]
- Why
- The parts are "ababcbaca", "defegde" and "hijhklij".
Example 2
- Input
- s = "eccbbbbdec"
- Output
- [10]
Constraints
- 1 <= s.length <= 500
- s consists of lower-case English letters
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 9. ⌘Enter runs, ⌘⇧Enter submits.