171. Excel 表列序号

  1. [题目链接](171. Excel 表列序号 - 力扣(LeetCode))

  2. 解题思路:其实就是26进制

  3. 代码

    class Solution:
        def titleToNumber(self, columnTitle: str) -> int:
            ans = 0
            for s in columnTitle:
                ans *= 26
                ans += ord(s) - ord('A') + 1
            return ans
    
posted @ 2025-01-09 10:34  ouyangxx  阅读(26)  评论(0)    收藏  举报