题目:
Related to question Excel Sheet Column Title
Given a column title as appear in an Excel sheet, return its corresponding column number.
解答:
简单的stringToint,就是转化26进制数,直接迭代即可
class Solution {
public:
int titleToNumber(string s) {
int res = 0;
int len = s.length();
for(int i = 0;i < len;++i)
{
res = res * 26 + s[i] - 'A' + 1;
}
return res;
}
};