Given a string columnTitle that represents the column title as it appears in an Excel sheet, return its corresponding column number.
For example:
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
...
We use analytics and advertising cookies to understand how the site is used and whether our ads on Facebook and Instagram work. They are set only if you accept. See our Privacy Policy for details.
Given a string columnTitle that represents the column title as it appears in an Excel sheet, return its corresponding column number.
For example:
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
...
An easy math problem, graded against 8 test cases (5 of them hidden).
Number theory, digit manipulation, and closed-form reasoning.
Reach for it when you see: Primes, digits, base conversion, or a problem with a formula hiding behind it.
More Math problems →Treat the column title as a base-26 number where A=1, B=2, ..., Z=26. Process left to right, multiplying the accumulated result by 26 and adding the current character's value.
For example, "AB" = 1 * 26 + 2 = 28.
The full reference solution in every supported language stays in the editor above - reveal it there once you have had a real attempt.
These apply to the pattern as a whole, not just this problem.