super ASCII string cost, C/C++ Programming

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'')
Posted Date: 7/18/2016 7:36:41 AM | Location : USA







Related Discussions:- super ASCII string cost, Assignment Help, Ask Question on super ASCII string cost, Get Answer, Expert's Help, super ASCII string cost Discussions

Write discussion on super ASCII string cost
Your posts are moderated
Related Questions
write a programme that allows a user to enter 5 distinct words and returns them as a single string

Scope Rules and Storage Classes The storage class verifies the life of a variable in terms of its duration or its scope. There are four storage classes : automatic static

padovan string c++ program

This assignment is to be undertaken individually - no group work is permitted. Background information This assignment is an exercise in simple object-oriented programming and, acco

Write a program to calculate e^x using the formula: e^x = 1 + x/1! + x^2/2! + x^3/3! + ...... Allow the user to enter the integer number x, then do the calculation in a loop (for

#include stdio.h #include math.h float discharge(float,float); void main()   {   char prompt;      float time,out,cr;   cr = 100e-6;   for (time = 0;time   {   /* call th

WAP TO PRINT ANY NAME ON SCREEN 10 TIMES void main () { int a=1; clrscr(); do { printf ("expertsmind\n"); a++; } while (a getch (); }

drawbacks in assignments in engeenirng

simple shopping cart

Why can't one open a file in a different directory like "..\test.dat"? A: Since " " is a tab character. You must employ forward slashes in your filenames, even on operating s