Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 481 Bytes

168._excel_sheet_column_title.md

File metadata and controls

28 lines (19 loc) · 481 Bytes

###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