Problem
Given a column title as appear in an Excel sheet, return its corresponding column number.
For example:
1 |
|
Example 1:
1 |
|
Example 2:
1 |
|
Example 3:
1 |
|
Explanation
-
This is a problem that asks us to convert a twenty-six hex to a decimal number.
-
We can start from the most right, ‘A’ is 1, so we can do ‘A’ - ‘A’ + 1 = 1, then multiple by 26 to the power of 0; ‘B’ is 2, we can do ‘B’ - ‘A’ + 1 = 2, multiple by 26 to the power of 0. Similarlly, the second right number multiple by 26’s to the power of 1.
Solution
1 |
|