Marks :10
: 3 | : 0
We are given a string s of length N consisting of only latin lowercase letters.
We can do the following operation atmost once:
Select two integers i , j (1 <= i <= j <= N), remove the string s[i....j] and concatenate the rest. Cost of such an operation is (j-i+1).
For example, in the string "abddefg",if we choose i=3 and j=5, the string gets changes to "abfg".
Find the minimum cost such that after the operation, the string contains only unique characters, or , the string does not contain any character whose occurrence is more than one.
Please note that if the string is already unique, the cost would be 0.
The first line contains T (1 <= T <= 100) - the number of test cases.
Each test case contains s (1 <= |s| <= 1e6) - the string consisting of latin lowercase letters a-z.
Sum of length of string <= 1e6 over all test cases.
For every test case, output one integer, the minimum cost.
3 aaaaa abbeb babbababab
4 2 8
For test - 1 ,'a' is the string which remains after the operation
For test - 2, 'aeb' is the string which remains after the operation.
For test - 3, 'ba' is the string which remains after the operation.
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.