LeetCode 171. 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 @ 2020-01-27 15:13  Shendu.CC  阅读(118)  评论(0编辑  收藏  举报