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 → 1
  • B → 2
  • C → 3
  • ...
  • Z → 26
  • AA → 27
  • AB → 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
Excel Column Conversion ProcessABZAAAB12262728Base-26 Conversion: Each position = 26^n, A=1, B=2, ..., Z=26
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
Asked in
Microsoft 45 Google 30 Amazon 25
180.0K Views
Medium Frequency
~15 min Avg. Time
2.1K Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen