java, Computer Engineering

Assignment Help:
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 and Output

SNo. Input Output
1
2
aaab
aabbbc


4
2



Explanation:

For Case1:
Need to retain a, b since these are unique characters in this string
Some of possible ways are

Delete two a''s and add one ''b''. Total cost = 8
Replace one a with b, and delete other ''a''. Total cost = 4.

For Case2:
Need to retain a, b, c since these are unique characters in this string
Some of possible ways are

Replace ''a'' and ''b'' with ''c''. Total cost = 2.
Delete one ''a'' and one ''b'' and then add two c''s. Total cost = 10.

Related Discussions:- java

Returns the information about tasks running, Returns the information about ...

Returns the information about tasks running int info = pvm_tasks( int where, int *ntask, struct pvmtaskinfo **taskp ) struct pvmtaskinfo {  int ti_tid; int ti_pt

Syntax and semantics - first-order logic, Syntax and Semantics: Propos...

Syntax and Semantics: Propositional logic is prohibited in its expressiveness: so just to represent true and false facts for the world. By a type of extending propositional lo

Explain topology method used in lan technology in detail, Explain topology ...

Explain topology method used in LAN technology in detail. LAN Topologies: Network topology is a physical schematic that shows interconnection of the various users. There are

Determine the equivalent binary form of decimal number, Solve the equation ...

Solve the equation 23.6 10 = X 2 for X Ans. 23.6 10 = X 2 So as to find X, firstly convert the Decimal number 23.610 in its Binary form. After that take the decimal inte

Explain time complexity in parallel algorithms, Q. Explain Time Complexity ...

Q. Explain Time Complexity in Parallel algorithms? As it takes place nearly everyone who implement algorithms wish to know how much of an individual resource (for example time

Explain bit slice ALUs, Bit Slice ALUs It was possible to manufacture ...

Bit Slice ALUs It was possible to manufacture smaller like 4 or 8 bits fixed point ALUs on a single IC chip. If these chips are constructed as expendable types then employing

Database, how create database design for pharmacy by diagram and query

how create database design for pharmacy by diagram and query

What do you mean by lock synchronization, Q. What do you mean by Lock Synch...

Q. What do you mean by Lock Synchronization? Lock Synchronization: In this method contents of an atom are updated by requester process and sole access is granted before atomic

What is gui status, What is GUI status? How to create /Edit GUI status? ...

What is GUI status? How to create /Edit GUI status? A GUI status is a subset of the interface elements used for a certain screen. The status comprises those elements that are c

What are parity generator and checker, What are parity generator and checke...

What are parity generator and checker? Ans: While a digital signal is transmitted, this may not be received correctly through the receiver. At the receiving end this may o

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd