Solvarch
DSA ProblemsProgressPlanRoadmapsReviewCheat SheetsCompaniesSystem DesignCS FundamentalsQuestion Bank
Theme
Problems

Partition Labels

Medium
greedystringtwo-pointers

Partition a string into as many parts as possible so that no letter appears in more than one part, and return the sizes of the parts (in order).

Input: one line, the string s. Output: the part sizes, space-separated.

Example 1
Input:
ababcbacadefegdehijhklij
Output:
9 7 8

"ababcbaca" "defegde" "hijhklij".

Example 2
Input:
eccbbbbdec
Output:
10

Constraints

  • 1 ≤ s.length ≤ 500
  • Lowercase English letters.
Watch a video walkthrough

Run your code against the sample tests, or Submit to run the full suite.