Skip to content

168 excel sheet column title

168. Excel Sheet Column Title

题目:

https://leetcode.com/problems/excel-sheet-column-title/

难度:

Easy

依旧26进制的反击,不过这个反击我做的没之前那个好,看了hint

class Solution(object):
    def convertToTitle(self, n):
        """
        :type n: int
        :rtype: str
        """
        ans = ''
        while n :
            ans = chr(ord('A') + (n - 1) % 26) + ans
            n = (n - 1) // 26
        return ans


我们一直在努力

apachecn/AiLearning

【布客】中文翻译组