AlgoUniversity
  • Go Back
Discussion
Partition Labels :

Author

Ayush Gangwani

Difficulty Level : Easy

Submissions : 400

Asked In : Flipkart

Marks :10

: 6 | : 2

You are given a string $$$S$$$ consisting of $$$n$$$ lowercase Latin letters. We want to partition the string into as many parts as possible so that each letter appears in at most one part.

Note that the partition is done so that after concatenating all the parts in order, the resultant string should be $$$S$$$.

Print a list of integers representing the size of these parts.

Input

The first line of input contains an integer $$$t$$$ $$$(1 \le t \le 10^4)$$$ — the number of testcases. The description of $$$t$$$ testcases follows.

The first and only line of each testcase contains a string $$$S$$$ $$$(1 \le |S| \le 10^5)$$$.

It is guaranteed that the sum of $$$|S|$$$ over all testcases does not exceed $$$10^5$$$.

Output

For each test case, print the list of partition sizes in a single new line.

Example

Input
2
ababcbacadefegdehijhklij
eccbbbbdec
Output
9 7 8 
10 

Note

In sample test case 1, The partition is $$$\texttt{"ababcbaca"}$$$, $$$\texttt{"defegde"}$$$, $$$\texttt{"hijhklij"}$$$. This is a partition so that each letter appears in at most one part. A partition like $$$\texttt{"ababcbacadefegde"}$$$, $$$\texttt{"hijhklij"}$$$ is incorrect, because it splits $$$S$$$ into less parts.

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.