Marks :15
: 14 | : 5
Alice has an integer array $$$A$$$ of size $$$N$$$. Alice has saved these integers in her computer but due to a virus attack some of the digits of her integers changed to some character of uppercase English alphabets from 'A' to 'J', but it is known that a unique digit is changed with a unique character.
For example, Let us suppose an integer was "1221321" and due to the virus,it is changed to "B2AB3A1", i.e., some of "1" is changed to the character 'B' and some of '2' is changed to the character 'A'. But it is not possible that this integer is changed to "BB21321" or "B22A321" because In "BB21321" two different digits are changed to a single character 'B' and in "B22A321" two same digits '1' is changed to two different characters.
You have been given array $$$A$$$ after the virus attack, Alice asked you to decode integers in this array in such a way that after decoding, the summation of all integers of the array is minimum possible.
Note: You have to decode the integers in such a way that no integer contain leading zeroes like 001, 0123, 0 etc.
The first line of input contains an integer $$$t$$$ $$$(1 \le t \le 10^4)$$$ — the number of testcases.The description of $$$t$$$ testcases follows.
The first line of each testcase contains an integer $$$N$$$ $$$(1 \le N \le 10^5)$$$ — the size of array $$$A$$$.
The second line of each testcase contains $$$N$$$ space separated alpha-numeric strings denoting the elements of array $$$A$$$. There will be atmost 10 characters in every element of array $$$A$$$.
It is guaranteed that sum of $$$N$$$ over all testcases does not exceed $$$10^5$$$.
For each testcase, print a single integer — the maximum possible sum of elements of array $$$A$$$.
32A1A 2AB3CB BC BAB3A1A3 AAB BD1
321 134 1426
In sample test case 1, one of the optimal ways is to assign 'A' = 1 and 'B' = 0, then array $$$A$$$ will be $$$[111,210]$$$ and hence sum = $$$111 + 210 = 321.$$$
In sample test case 2, one of the optimal ways is to assign 'A' = 0, 'B' = 1 and 'C' = 2, then array $$$A$$$ will be $$$[21,12,101]$$$ and hence sum = $$$21+12+101 = 134.$$$
In sample test case 3, one of the optimal ways is to assign 'A' = 1, 'B' = 2 and 'D' = 0, then array $$$A$$$ will be $$$[1113,112,201]$$$ and hence sum = $$$1113+112+201 = 1426.$$$
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.