3 lines recursive Python solution


  • 0
    J
    class Solution(object):
        def convertToTitle(self, n):
            """
            :type n: int
            :rtype: str
            """
            ab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
            pre = self.convertToTitle((n-1)/26) if (n-1)/26 != 0 else ''
            return pre + ab[(n - 1) % 26]

Log in to reply
 

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