mycode   90.39%

class Solution(object):
def titleToNumber(self, s):
"""
:type s: str
:rtype: int
"""
res = 0
for alpha in s:
res = (ord(alpha) - 64) + res*26
return res

参考:

carry实际上就是十进制中的指数

class Solution(object):
def titleToNumber(self, s):
"""
:type s: str
:rtype: int
"""
def _map(ch):
chn = ord(ch)
assert chn >= ord('A') and chn <= ord('Z')
return chn - ord('A') + 1
lens = len(s)-1
carry = 1
val = 0
while lens >=0:
num = _map(s[lens])*carry
val = val + num
carry *= 26
lens -= 1
return val

最新文章

  1. SqlServer windowss身份登陆和sa身份登陆
  2. NPOI操作excel
  3. (转)python爬取拉勾网信息
  4. iOS启动图和开屏广告图,类似网易
  5. 【poj3537】 Crosses ans Crosses
  6. 多线程——GCD
  7. Programming Impala Applications
  8. Struts2学习笔记1
  9. diff函数的实现——LCS的变种问题
  10. 配置并学习微信JS-SDK(3)&mdash;菜单接口
  11. CentOS 7安装Teamviewer 12
  12. Java集合框架学习(一)List
  13. centOS 6启动流程
  14. Problem : 1013 ( Digital Roots )
  15. 4.namespace
  16. 【原创】大数据基础之Hive(5)hive on spark
  17. 移动Web端资源整合
  18. VS2012 VS2015打开项目加载失败
  19. GameObject.Find与Transform.Find的区别
  20. JMeter - Perfmon - ServerAgent

热门文章

  1. C#下载图片,用户选择保存路径
  2. scrapy框架设置代理ip,headers头和cookies
  3. RocketMQ 源码分析 —— Message 发送与接收
  4. Vue组件通信方式(8种)
  5. css的样式问题
  6. 6U VPX 加固智能计算异构服务器
  7. h5 实现页面上拉加载更多数据
  8. Atcoder Regular 098 区间Pre=Xor Q询问区间连续K去最小值最小极差
  9. SpringFramework中的BeanWrapper丶PropertyEditor
  10. source insight支持查看makefile、kconfig以及.s代码方法