首页 > 其他 > 详细

171. Excel表列序号

时间:2020-04-03 16:58:55      阅读:46      评论:0      收藏:0      [点我收藏+]
 1 class Solution 
 2 {
 3 public:
 4     int titleToNumber(string s) 
 5     {
 6         unordered_map<char,int> hash;
 7         for(int i = 1;i <= 26;i ++) hash[A + i - 1] = i;
 8         int res = 0;
 9         int n = s.size();
10         for(int i = n - 1;i >= 0;i--) res += hash[s[i]] * pow(26,n - i - 1);
11         return res;
12     }
13 };

 

171. Excel表列序号

原文:https://www.cnblogs.com/yuhong1103/p/12627366.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!