LeetCode 171 Excel Sheet Column Number
2015-12-04 15:52
369 查看
题目描述
Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.
For example:
[code]A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28
Credits:
Special thanks to @ts for adding this problem and creating all test cases.
分析
相似题目:LeetCode 168 Excel Sheet Column Title实质上就是26进制转成10进制。
代码
[code] public static int titleToNumber(String s) { int n = 0; int p = 1; for (int i = s.length() - 1; i >= 0; i--) { n += (s.charAt(i) - 'A' + 1) * p; p *= 26; } return n; }
相关文章推荐
- 图片轮播器
- gnuradio模块的数据输出
- 启动 asmca 时出现 No protocol specified 错误的解决办法
- android button设计模拟器
- python入门常见错误
- Bean的初始化和销毁
- IOS与ReactNative
- IOS 启动画面设置
- H5页面audio多声音解决方法
- 忘记MySQL root密码如何重置。
- iOS 开发中一些不常用技巧
- 10008---jQuery效果--淡入淡出
- XCode 7上传遇到ERROR ITMS-90535 Unexpected
- iOS之 随笔-静态库创建Xcode7
- iOS开发之XCode模拟器不能连接网络
- JQuery学习笔记
- Eclipse开发工具组合键介绍
- 给用户添加sudo权限
- python批量修改文件
- PHP正则匹配取文章首图代码