

"qvmwtmzzse" is the given string. We can make the first two partitions as ‘q’, ‘v’, but ‘m’ can not be an individual partition because there is another occurrence of m at index 6. So, the minimum length of the third partition is from index 3 to 6 and the partition is "mwtm". Similarly, the next partitions are "zz", ‘s’, ‘e’.
The first line of input contains an integer ‘T’, denoting the number of test cases. The test cases follow.
The first line of each test case contains a string ‘S’ consisting of lowercase English letters.
Print the size of the partitions of the string on a single line separated by space. Note that you need to maximize the number of partitions.
Print the output of each test case in a new line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1<= T <= 10^3
1 <= |S| <= 10^3
Where |S| is the size of the given string ‘S’.
Time Limit: 1 sec
Approach: The idea is to divide the whole string into partitions such that one partition covers all the appearances of a letter. Whenever we encounter all appearances of all the letters in the current partition is covered, then, increase the number of partitions.
The steps are as follows:
Approach: The idea is to store the last appearance of each letter in an array. We can save O(N) time by doing this as we won’t have to calculate for each letter in the iteration.
The rest of the steps are similar to the previous approach.
The steps are as follows: