Partition Labels
Split s into as many nonempty contiguous parts as possible so that each letter occurs in only one part. Return the lengths of those parts in order.
Example 1
S = "abacdeef"[3,1,1,2,1]Explanation
a ties indices 0..2 together; c and d are separate, both e letters stay together, and f is separate.
Example 2
S = "ababcbacadefegdehijhklij"[9,7,8]Explanation
Last occurrences force ranges 0..8, 9..15 and 16..23 of lengths 9,7,8.
Example 3
S = "aaaa"[4]Explanation
Every a must remain in one part of length four.
Constraints
- 1 <= len(s) <= 500
- s contains lowercase English letters
Function contract
partitionLabelsArguments: jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 35 cases, on your device.
"abacdeef"