LeetCode 171 Excel Sheet Column Number

Problem:

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 

Summary:

将二十六进制数字转为十进制。

Analysis:

 1 class Solution {
 2 public:
 3     int titleToNumber(string s) {
 4         int len = s.size();
 5         int res = 0;
 6         
 7         for (int i = 0; i < len; i++) {
 8             res += (s[len - i - 1] - 'A' + 1) * pow(26, i);
 9         }
10         
11         return res;
12     }
13 };
原文地址:https://www.cnblogs.com/VickyWang/p/6003532.html