171. Excel 表列序号 力扣(简单) 想不明白的题

171. Excel 表列序号

给你一个字符串 columnTitle ,表示 Excel 表格中的列名称。返回该列名称对应的列序号。

例如,

    A -> 1
    B -> 2
    C -> 3
    ...
    Z -> 26
    AA -> 27
    AB -> 28 
    ...

题解:https://leetcode-cn.com/problems/excel-sheet-column-number/solution/gong-shui-san-xie-tong-yong-jin-zhi-zhua-y5fm/

类似题:

168. Excel表列名称 

对应博客中地址:https://www.cnblogs.com/stepping/p/14952142.html

代码:

class Solution {
public:
    int titleToNumber(string columnTitle) {
    int ans=0;;
    for (auto i:columnTitle)
        ans=ans*26+(i-'A'+1);
    return ans;
    }
};
原文地址:https://www.cnblogs.com/stepping/p/15085077.html