Answer to Question #45393 in Java | JSP | JSF for Dolly

Question #45393
Problem : Super ASCII String Cost
A string S is said to be "Super ASCII", if it contains the character frequency equal to their ascii values. String will contain only lower case alphabets ('a'-'z') and the ascii values will starts from 1 (i.e ascii value of 'a' is 1 and 'z' is 26). Now given a string S, you can perform operations, namely, add, delete and replace of any character present in the string. Every operation will consists of following costs

add = 2 unit
replace = 1 unit
delete = 3 unit

Your task is to convert the string to super ascii with the minimum cost. While converting the string to super ascii, the final string should contain the same characters as in the input string.
Input Format:

First line starts with T i.e. number of test cases, and then T lines will follow each containing a string "S".
Output Format:

Print the minimum cost of conversion for each string to a Super Ascii string.
Constraints:
1<=T<=100
1<=|S|<=300, S will contains only lower case alphabets ('a'-'z').
Sample Input
0
Expert's answer

Answer in progress...

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS