171. Excel 表列序号
给你一个字符串 columnTitle ,表示 Excel 表格中的列名称。返回该列名称对应的列序号。
例如,
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
...
类似题:
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; } };