Problem of the day
You are given a string STR representing the column title in an Excel Sheet. You need to find its corresponding column number.
For example: A corresponds to 1, B to 2, C to 3, … , Z to 26, AA to 27, .. and so on.
The first line of input contains a single integer T, representing the number of test cases or queries to be run.
Then the T test cases follow.
The first and only line of each test case contains a string STR denoting the column title. It is guaranteed that all the characters would be capital English alphabets.
Output Format:
For each test case, you need to return the corresponding excel column number of STR.
The output of each query must be printed in a new line.
Note:
You are not required to print the expected output, it has already been taken care of. Just implement the function.
1 ≤ T ≤ 50
1 ≤ |STR| ≤ 12
where 'T' denotes number of testcases, and |STR| denotes the length of the string.
Time Limit : 1 sec
3
A
AB
F
1
28
6
The first test case, STR = “A”. This corresponds to column number 1.
The second test case, STR = “AB”. This corresponds to column number 28.
The third test case, STR = “F”. This corresponds to column number 6.
3
AZ
COD
ZZZ
52
2422
18278