Excel Sheet Column Title

Given an integer columnNumber, return its corresponding column title as it appears in an Excel sheet.

Excel column titles are labeled using uppercase English letters in a 1-indexed manner:

  • 1 corresponds to A
  • 2 corresponds to B
  • 26 corresponds to Z
  • 27 corresponds to AA

Return the column title string for the given columnNumber.

Example 1
InputcolumnNumber = 1
Output"A"
Column number 1 corresponds directly to the first letter, A.
Example 2
InputcolumnNumber = 28
Output"AB"
After Z, the next columns continue as AA, AB, so column number 28 is AB.

Constraints

  • 1 <= columnNumber <= 2^31 - 1

Asked at 8 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate