171_Excel Sheet Column Number
Given a column title as appear in an Excel sheet, return its corresponding column number.
For example:
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
...Example 1:
Input: "A"
Output: 1Example 2:
Input: "AB"
Output: 28Example 3:
Input: "ZY"
Output: 701Solution:
Idea:
This problem is basically the problem of converting a string representing a base 26 number to the corresponding integer.
Note that "A" correspond to 1 not 0.
Time Complexity: where n is the number of characters in the input string.
Space Complexity:
Code 1: Iterative approach
Code 2: Recursive approach
Last updated