Python simple solution


  • 4
    F
    class Solution(object):
        def convertToTitle(self, n):
            """
            :type n: int
            :rtype: str
            """
            res = ''
            base = ord('A')
            while n:
                n, r = divmod(n - 1, 26)
                res = '{}{}'.format(chr(base + r), res)
            return res

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.