In a spreadsheet, columns are labeled alphabetically as follows:
A, B, C, ..., Z, AA, AB, ..., AZ, BA, BB, ...
Each column title can be interpreted as a base-26 number, where:
'A' represents 1,
'B' represents 2,
...,
'Z' represents 26.
Your task is to convert the given column title into its corresponding column number.
Input: columnTitle = "C"
Output: 3
Explanation:
C corresponds to the 3rd column.
Input: columnTitle = "AZ"
Output: 52
Explanation:
'A' = 1 × 26¹ = 26 'Z' = 26 × 26⁰ = 26 Total = 26 + 26 = 52
Input: columnTitle = "BX"
Output: 76
Explanation:
'B' = 2 × 26¹ = 52 'X' = 24 × 26⁰ = 24 Total = 52 + 24 = 76
Accepted:
Submission: