Excel Sheet Column Title - Problem
Given an integer columnNumber, return its corresponding column title as it appears in an Excel sheet.
For example:
- A → 1
- B → 2
- C → 3
- ...
- Z → 26
- AA → 27
- AB → 28
- ...
Input & Output
Example 1 — Single Letter
$
Input:
columnNumber = 1
›
Output:
"A"
💡 Note:
The first column in Excel is labeled 'A'
Example 2 — Double Letter Start
$
Input:
columnNumber = 28
›
Output:
"AB"
💡 Note:
After Z (26), comes AA (27), then AB (28)
Example 3 — Large Number
$
Input:
columnNumber = 701
›
Output:
"ZY"
💡 Note:
701 converts to ZY using base-26 conversion with adjustment
Constraints
- 1 ≤ columnNumber ≤ 231 - 1
Visualization
Tap to expand
Understanding the Visualization
1
Input
Column number (integer)
2
Convert
Base-26 with 1-indexing adjustment
3
Output
Excel column title (string)
Key Takeaway
🎯 Key Insight: Excel uses a modified base-26 system where we subtract 1 before each division to handle 1-based indexing
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code