//#171 Excel Sheet Column Number
//8ms 100%
class Solution {
public:
int titleToNumber(string s)
{
int s_num(0);
int j(0);
for(string::reverse_iterator r_it = s.rbegin(); r_it != s.rend(); r_it ++)
{
int add = *r_it - '@';
s_num = s_num + add * pow(26, j);
j ++;
}
return s_num;
}
};
[Leetcode]#171 Excel Sheet Column Number
最新推荐文章于 2024-11-17 18:49:52 发布