Convert an Excel-style column label like A, Z, AA, or FXSHRXW into its corresponding column number.
Problem
You are given a string columnTitle that represents an Excel column title.
Excel columns are labeled using uppercase letters starting from A:
A= 1B= 2- ...
Z= 26AA= 27AB= 28
Your task is to return the numeric column index represented by the title.
Treat the title as a base-26 number where A maps to 1 and Z maps to 26, rather than 0 to 25.
Notes
- The input contains only uppercase English letters.
- The answer fits in a 32-bit signed integer for standard interview constraints.
Input Format
- A single string
columnTitle. columnTitleconsists only of uppercase lettersAtoZ.
Output Format
- Return a single integer: the Excel column number for
columnTitle.
Constraints
columnTitlecontains only uppercase lettersA-Z- The result fits in a signed 32-bit integer
Example 1
Input
columnTitle = "A"
Output
1
Explanation
A corresponds to 1.
Example 2
Input
columnTitle = "AB"
Output
28
Explanation
AB = 1 × 26 + 2 = 28.
Show 1 more example
Example 3
Input
columnTitle = "ZY"
Output
701
Explanation
ZY = 26 × 26 + 25 = 701.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.