Leetcode 171. Excel Sheet Column Number | | Leetcode 171. Excel Sheet Column Number 文章作者:Tyan博客:noahsnail.com | CSDN | 简书 1. Description 2. Solution Version 1 12345678910class Solution: def titleToNumber(self, s): result = 0 mapping = {chr(64+i): i for i in range(1, 27)} s = list(s) s.reverse() for index, ch in enumerate(s): result = result + mapping[ch] * math.pow(26, index) return int(result) Version 2 123456class Solution: def titleToNumber(self, s): result = 0 for ch in s: result = result * 26 + ord(ch) - 64 return result Reference https://leetcode.com/problems/excel-sheet-column-number/ 如果有收获,可以请我喝杯咖啡! 赏 微信打赏 支付宝打赏