LeetCode 763 Partition Labels - Problem Statement

The problem

Partition a string into as many parts as possible so that each letter appears in at most one part.

With s = "ababcbacadefegdehijhklij":

  • "ababcbaca" contains all 'a', 'b', 'c'. Length 9.
  • "defegde" contains all 'd', 'e'. Length 7.
  • "hijhklij" contains all 'h', 'i', 'j', 'k', 'l'. Length 8.
  • Result: [9, 7, 8].

With s = "eccbbbbdec":

  • "eccbbbbdec" must be one part (letters overlap throughout).
  • Result: [10].

Return the list of partition sizes.

Constraints: 11 \le s.length 500\le 500. All lowercase letters.