[Lc]171Excel表列序号
Contents
题目

题解
和168正好相反嘛 这题就简单多了,挨个取字母变成数字就可以了,注意有:
- 每次是乘26
 - 每次要+1,和168的原因一样,这个是伪26进制,从1开始
 
class Solution {
public:
    int titleToNumber(string s) {
        long n = 0;
        for(auto &c:s){
            n = n*26 + c-'A'+1;
        }
        return n;
    }
};
    Author ChrisHRZ
LastMod 2020-05-08