Parse A1 Cell References Into Row And Column Indices
Last updated: November 29, 2026
Quick Overview
Write functions that convert spreadsheet column letters to a zero-based index and back, then parse a reference like `$B$3` or a range like `C5:A1` into normalized row and column bounds.
Sigma Computing
November 29, 20260
0
0 solved
Write functions that convert spreadsheet column letters to a zero-based index and back, then parse a reference like `$B$3` or a range like `C5:A1` into normalized row and column bounds.
Sigma's workbook surface looks and feels like a spreadsheet, so a warm-up on spreadsheet addressing is a natural phone-screen question. The interviewer checks off-by-one discipline in the bijective base-26 conversion and clean input validation.
What the Interviewer Expects
- Recognize column letters as bijective base 26 (no zero digit), not plain base 26
- Implement both directions and show they round-trip
- Handle absolute markers ($) and lowercase input
- Normalize ranges so the top-left corner comes first regardless of how the user typed it
- Reject malformed references like A0 or 1A with a clear error
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
- How would you support whole-column references like B:D or whole-row references like 3:7?
- How would you shift relative references when a formula is copied two rows down, while leaving $-anchored parts fixed?
- What changes if sheets are named, as in 'Q3 Plan'!A1?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
col_to_index('A') == 0,'Z' == 25,'AA' == 26,'ZZ' == 701.index_to_colis the inverse.parse_ref('$B$3')returns(row, col) = (2, 1), zero-based.parse_range('C5:A1')returns...
High-Level Design
Column letters are a bijective base-26 numeral: digits run 1..26 with no zero. Reading left to right, n = n*26 + digit where A=1. Subtract one at the end for zero-based output. Going back, convert...