String protocol solution codechef
An input stringof length is transferred through the network using a special protocol. The protocol can send the string through a series of operations. In one operation, we can choose a lowercase english alphabet and do one of the following:
- Transfer copy of through the network.
- Transfer copies of through the network.
Each of the above transfers takeunit of time.
Find the minimum time in which we can transfer the entire stringthrough the network.
- The first line will contain – the number of test cases. Then the test cases follow.
- First line of each test case contains – the length of the string .
- Second line of each test case contains the string .
Output Format String protocol solution codechef
For each test case, output in a single line, the minimum time required to transfer the string.
- Sum of over all test cases does not exceed .
- String contains lowercase english alphabets only.
Sample Input 1 String protocol solution codechef
2 5 cbcdc 6 aabeee
Sample Output 1
Explanation String protocol solution codechef
Test Case: String can be transferred through following operations: send copy of character , send copy of character , send copy of character , send copy of character , and send copy of character . Thus, total operations are required.
Test Case: String can be transferred through following operations: send copies of character , send copy of character , send copy of character , and send copies of character . Thus, total operations are required