DIY: Partition Labels

Solve the interview question "Partition Labels" in this lesson.

Problem statement

You are given a string, s, of lowercase English letters. We want to partition this string into as many parts as possible such that each letter appears in at most one part. Return a list of integers representing the size of these parts.

Input

The input will contain a string called s. The following is an example input:

"caedbdedda"

Output

The output will be a list of integers representing the size of partitions created from the string s. For the above input, the output will be:

[1,9]

The partition will be "c" and "caedbdedda".

Coding exercise

Implement the partition_labels(s) function, where s is the string. The function returns a list of integers representing the size of partitions created from the string s.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.