Partition Labels
MediumGreedy
Decode it first. Clues, constraints, pattern and plan before any code.Cut the string s into as many pieces as possible so that every letter appears in at most one piece. Return the sizes of the pieces, in order.
s = "abcabdde" → [5, 2, 1] ("abcab", "dd", "e")
s = "caedbdedda" → [1, 9] ("c", "aedbdedda")
s = "eccbbbbdec" → [10] (one piece holds everything)Constraints
1 <= s.length <= 500scontains only lowercase English letters.