Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Excel Sheet Column Number

XPChallenge Points: 10
levelLevel: Easy

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.

Example 1:

Input: columnTitle = "C"

Output: 3

Explanation:

C corresponds to the 3rd column.

Example 2:

Input: columnTitle = "AZ"

Output: 52

Explanation:

'A' = 1 × 26¹ = 26 'Z' = 26 × 26⁰ = 26 Total = 26 + 26 = 52

Example 3:

Input: columnTitle = "BX"

Output: 76

Explanation:

'B' = 2 × 26¹ = 52 'X' = 24 × 26⁰ = 24 Total = 52 + 24 = 76

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result