Partition Labels Problem

Partition Labels Problem — ExecCode Easy DSA Practice

Solve the Partition Labels problem on ExecCode. Free online easy DSA practice in Greedy. Write and run code in Java, C++, Python — no signup required to run.

Problem description

You are given a string s. Partition it into as many parts as possible so that each letter appears in at most one part. Return a list of integers representing the size of each part, in order.

Examples

Input s = "ababcbacadefegdehijhklij"; Output [9, 7, 8]. Input s = "eccbbbbdec"; Output [10]. Input s = "abac"; Output [3, 1]

Constraints

1 ≤ s.length ≤ 500 s consists of lowercase English letters only.

Practice Partition Labels free on ExecCode. Browse DSA problems, topic map, and placement guides.