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
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code