Excel Sheet Column Number - Problem
Given a string columnTitle that represents the column title as it appears in an Excel sheet, return its corresponding column number.
In Excel, columns are labeled as:
A→ 1B→ 2C→ 3- ...
Z→ 26AA→ 27AB→ 28- ...
This is essentially converting from base-26 numbering system to decimal, where A=1, B=2, ..., Z=26.
Input & Output
Example 1 — Single Character
$
Input:
columnTitle = "A"
›
Output:
1
💡 Note:
A is the first column, so it corresponds to column number 1
Example 2 — Two Characters
$
Input:
columnTitle = "AB"
›
Output:
28
💡 Note:
A=1, B=2. Result = 1×26 + 2 = 28. This is column AB which comes after Z (26) and AA (27)
Example 3 — Last Single Character
$
Input:
columnTitle = "Z"
›
Output:
26
💡 Note:
Z is the 26th letter, corresponding to column number 26
Constraints
- 1 ≤ columnTitle.length ≤ 7
- columnTitle consists only of uppercase English letters
- columnTitle is in the range ["A", "FXSHRXW"]
Visualization
Tap to expand
Understanding the Visualization
1
Input
Excel column title as string
2
Process
Convert from base-26 to decimal
3
Output
Column number as integer
Key Takeaway
🎯 Key Insight: Excel columns follow base-26 numbering where each letter position represents a power of 26
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code