[LeetCode]Excel Sheet Column Number

public class Solution {
    public int titleToNumber(String s) {
        int result = 0;
        int tmp = 1;
        for (int i = s.length() - 1; i >= 0; i--) {
            result += (s.charAt(i) - 'A' + 1) * tmp;
            tmp *= 26;
        }
        return result;
    }
}

 

posted @ 2015-12-01 15:01  Weizheng_Love_Coding  阅读(105)  评论(0编辑  收藏  举报