Excel Sheet Column Title

EasyMathbase conversion

Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.

Practice this as a mock interviewFree to start, no account needed

Problem

In a spreadsheet application, columns are labeled with letters instead of numbers. The first column is A, the 26th column is Z, the 27th column is AA, the 28th is AB, and so on. Given a positive integer columnNumber, return its corresponding spreadsheet column title as a string. The labeling follows a sequence similar to counting in base 26, but with an important twist: there is no digit that represents zero. Each position uses the letters A through Z (mapping to the values 1 through 26), so the scheme behaves like a *bijective* base-26 numeral system rather than ordinary positional notation.

Examples

Input: columnNumber = 1
Output: "A"
The first column is labeled `A`.
Input: columnNumber = 28
Output: "AB"
Columns 1 through 26 are `A` through `Z`, column 27 is `AA`, so column 28 is `AB`.
Input: columnNumber = 701
Output: "ZY"
701 maps to `Z` (26) in the high place and `Y` (25) in the low place: 26*26 + 25 = 701.

Constraints

  • `1 <= columnNumber <= 2^31 - 1`
  • The answer fits comfortably in a standard string (at most 7 characters).

What the interviewer grades

A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.

More base conversion problems