Skip to main content

168. Excel Sheet Column Title

easyAsked at Bloomberg

Convert a positive integer to its Excel-style column title (A, B, ..., Z, AA, AB, ...). Bloomberg uses this to test whether you can handle a base-26 conversion with the 1-indexed twist that breaks standard base-conversion code.

By Alex Chen, Founder, InterviewChamp.AI · Last verified

Source citations

Public interview reports confirming this problem appears in Bloomberg loops.

  • Glassdoor (2026-Q1)Bloomberg SWE phone-screen reports cite Excel Sheet Column Title because finance teams care about spreadsheet-style data.
  • Blind (2025-11)Bloomberg new-grad reports note this for the 1-indexed base-26 edge case.

Problem

Given an integer columnNumber, return its corresponding column title as it appears in an Excel sheet. For example: A -> 1, B -> 2, ..., Z -> 26, AA -> 27, AB -> 28, ...

Constraints

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

Examples

Example 1

Input
columnNumber = 1
Output
"A"

Example 2

Input
columnNumber = 28
Output
"AB"

Example 3

Input
columnNumber = 701
Output
"ZY"

Example 4

Input
columnNumber = 2147483647
Output
"FXSHRXW"

Approaches

1. Repeated subtract-1 then mod 26

Each iteration, subtract 1 to convert from 1-indexed to 0-indexed, take mod 26 for the character, divide by 26.

Time
O(log26(n))
Space
O(log26(n))
function convertToTitle(columnNumber) {
  let result = '';
  let n = columnNumber;
  while (n > 0) {
    n--;
    result = String.fromCharCode(65 + (n % 26)) + result;
    n = Math.floor(n / 26);
  }
  return result;
}

Tradeoff: The canonical answer. The 'n--' trick converts 1-indexed (A=1) to 0-indexed (A=0) before mod. Bloomberg interviewers specifically grade whether you spot this.

2. Recursive

Pull off the last digit, recurse on the rest.

Time
O(log26(n))
Space
O(log26(n))
function convertToTitleRec(columnNumber) {
  if (columnNumber === 0) return '';
  const n = columnNumber - 1;
  return convertToTitleRec(Math.floor(n / 26)) + String.fromCharCode(65 + (n % 26));
}

Tradeoff: More elegant for some, but uses stack and harder to debug. The iterative version is the production-shippable answer.

Bloomberg-specific tips

Bloomberg interviewers test this specifically because the OBVIOUS base-26 conversion is WRONG. Excel columns are 1-indexed: A=1, not A=0. So Z=26 maps to a SINGLE digit (Z), not 10 (AB). State 'this is base-26 but with a 1-indexed offset — I'll subtract 1 each iteration' before coding.

Common mistakes

  • Forgetting the n-- step — produces empty-string output for Z, AZ, etc.
  • Confusing 1-indexed with 0-indexed alphabets.
  • Building the string forward instead of prepending — produces reversed output.

Follow-up questions

An interviewer at Bloomberg may pivot to one of these next:

  • Excel Sheet Column Number (LC 171) — reverse: title to number.
  • Roman to Integer (LC 13) — another non-standard base conversion.
  • Integer to English Words (LC 273) — harder string-mapping problem.

Solve it now

Free. No sign-up. Python and JavaScript run instantly in your browser.

Output

Press Run or Cmd+Enter to execute

FAQ

Why subtract 1 in the loop?

Because Excel is 1-indexed (A=1, not A=0). Standard base-26 conversion assumes 0-indexed. The n-- adjusts before each mod so 26 -> Z, not AA.

Will Bloomberg ask the reverse?

Often as a follow-up. LC 171 — multiply by 26 and add (char - 'A' + 1).

Free learning resources

Curated free links for this problem.

Practice these live with InterviewChamp.AI

Drill Excel Sheet Column Title and other Bloomberg interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.

Practice these live with InterviewChamp.AI →