leetcode 168 Excel Sheet Column Title

Jun 1, 2017


leetcode 168

class Solution(object):
    def convertToTitle(self, n):
        """
        :type n: int
        :rtype: str
        """
        ret = ''
        while n > 0 :
            ret = ret + '%c'%(64 + (n % 26 == 0 and 26 or n % 26))
            n = int((n - 1) / 26)
        return ret[::-1]