Back to DSA

Partition Labels

medium
Acceptance: 54%
GreedyStringsTwo Pointers

Split a string into the maximum number of contiguous segments such that every character appears in at most one segment. Return the lengths of those segments in order.

Examples

Example 1:
Input:s = "xyzxabcabc"
Output:[4,6]
Example 2:
Input:s = "abcabc"
Output:[6]

Hints

00:00
1234567