A string S of lowercase English letters is given.

We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representing the size of these parts.

Input: S = “ababcbacadefegdehijhklij”

Output: [9,7,8]

Explanation:

The partition is “ababcbaca”, “defegde”, “hijhklij”.

This is a partition so that each letter appears in at most one part.

A partition like “ababcbacadefegde”, “hijhklij” is incorrect, because it splits S into less parts.

String=input("Enter the String: ") i=0 N=len(String) list1=[] while i<N: index=String.rindex(String[i]) j=i while (j<index): if(String.rindex(String[j])>index and j!=i): index=String.rindex(String[j]) j+=1 list1.append(String[i:index+1]) i=index+1 length=[] for i in list1: length.append(len(i)) print(length)

Input:

Enter the String: ababcbacadefegdehijhklij

Output:

[9, 7, 8]

exec. on terminal

**More Codes to Fcuk**

- Alphabet pyramid
- Find prime numbers between lower and upper ranges
- Prime Factor
- Find the sum of positive even numbers
- An integer interval [a,b], Find the minimum size of a set S.
- Country A and B, how many years the population of A surpasses B.
- Identify pH level
- Find the Perfect Number
- Find out if a word is a palindrome or not
- Find next Palindrome of N number.
- The writing bot Question. A scientist has created a writing bot. Read and write activity needs to be captured.
- Total Number of Odds in the list
- Partition this string into as many parts as possible.
- Leap year
- LCM of two numbers
- Greatest of three numbers
- Find the Gravitational Force Acting Between Two Objects.
- Find the missing element in geometric progression
- Find the GCD Greatest common divisor
- convert a given float number to integer