171.Excel Sheet Column Number

 

 

class Solution:
    def titleToNumber(self, s: str) -> int:
        ans = 0
        for i in range(len(s)):
            ans = ans * 26 + ord(s[i])-64
        return ans

 

posted @ 2020-05-09 14:52  星海寻梦233  阅读(111)  评论(0编辑  收藏  举报