Excel Column Number InterviewBit Solution
Problem: Excel Column Number
Problem Description:
Given a column title A as appears in an Excel sheet, return its corresponding column number.
Problem Constraints
1 <= |A| <= 100
Input Format
First and only argument is string A.
Output Format
Return an integer
Example Input
Input 1:
1
Input 2:
28
Example Output
Output 1:
"A"
Output 2:
"AB"
Example Explanation
Explanation 1:
1 -> "A"
Explanation 2:
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
Approach
This question is about base conversion, just think what would you have done if you have given a binary (base-2) instead of base-26.
Time & Space Complexity:
Time Complexity: O(N)
- N is the size of the string.
Space Complexity: O(1)
Comments