LeetCode 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 
class Solution {
public:
    int titleToNumber(string s) {
        int ret = 0;
        int help = 1;
        for (int i = s.size() - 1;i >= 0;--i)
        {
            ret += (s[i] - 'A' + 1)*help;
            help *= 26;
        }
        return ret;
    }
};
原文地址:https://www.cnblogs.com/csudanli/p/5387136.html