Excel Sheet Column Number
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 neededProblem
In a spreadsheet application, columns are labeled with uppercase letters instead of numbers. The labeling works like this:
```
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
...
```
Given a string columnTitle representing a column label exactly as it would appear in the spreadsheet header, return the corresponding column number as an integer.
This is essentially a **base-26 number system**, except there is no digit for zero. Each character contributes a value from 1 (for 'A') to 26 (for 'Z'), and each position is weighted by a power of 26, with the leftmost character being the most significant.
For example, "ZY" is computed as 26 * 26 + 25 = 701.
Examples
Constraints
- `1 <= columnTitle.length <= 7`
- `columnTitle` consists only of uppercase English letters (`'A'` to `'Z'`).
- `columnTitle` is within the range `["A", "FXSHRXW"]`, which corresponds to column numbers from `1` up to about `2^31 - 1`.
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.