Leetcode 171 Excel Sheet Column Number 难度:0

https://leetcode.com/problems/excel-sheet-column-number/

class Solution {
public:
    int titleToNumber(string s) {
        int ans = 0;
        for(int i = 0;i < s.length();i++)
        {
            ans *= 26;
            ans += s[i] - 'A' + 1;
        }
        return ans;
    }
};

  

posted @ 2015-08-25 16:40  雪溯  阅读(111)  评论(0编辑  收藏  举报