Given a column title as appear in an Excel sheet, return its corresponding column number.(给定一个Excel表的列名,返回相应列的数字)
For example:
A -> 1
B -> 2
C -> 3
…
Z -> 26
AA -> 27
AB -> 28
1.个人分析
这道题在《剑指Offer》中看到过,求列名对应的数字本质上是求27进制数的加法,与十进制的加法类似,在这里每逢27进一,也就是A+Z=AA。
2.个人解法
int titleToNumber(string s)
{
int len = s.length();
if(0 == len)
return 0;
int letterVal