Convert Between Ads Manager Spreadsheet Column Labels and Numbers
Last updated: November 29, 2026
Quick Overview
Ads Manager exports use spreadsheet column labels A, B, ..., Z, AA, AB, and so on. Write functions that convert a positive column number to its label and a label back to its number.
Meta
November 29, 20260
0
0 solved
Ads Manager exports use spreadsheet column labels A, B, ..., Z, AA, AB, and so on. Write functions that convert a positive column number to its label and a label back to its number.
A short Meta screen question about bijective base-26, where the classic bug is treating it like ordinary base 26 with a zero digit. The interviewer watches whether you catch the off-by-one on Z, AZ and ZZ and test both directions.
What the Interviewer Expects
- Recognize there is no zero digit, so this is bijective base 26
- Handle the off-by-one by subtracting 1 before each mod
- Write both directions and round-trip test them
- Trace Z, AA, AZ and ZZ
- State logarithmic complexity
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- What changes for a base-k alphabet?
- How would you validate malformed labels like lowercase or empty strings?
- How would you list all labels from A up to a given label lazily?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Two functions: to_label(n) for n >= 1 and to_number(label) for a non-empty uppercase string. Examples: 1 -> A, 26 -> Z, 27 -> AA, 52 -> AZ, 702 -> ZZ, 703 -> AAA. Round trips must be exact....
High-Level Design
In ordinary base 26 the digits would be 0..25, but labels use 1..26 (A..Z) with no zero. Label to number is easy Horner evaluation: n = n * 26 + (ch - 'A' + 1).
Number to label needs a shift. At ea...