python recursion


  • 0
    A

    Surprisingly low acceptance rate for this one, just share my super beginner code here.

    class Solution(object):
        def convertToTitle(self, n):
            """
            :type n: int
            :rtype: str
            """
            if n <= 26:
                return chr(n -1 + 65)
            
            return self.convertToTitle((n-1)//26) + chr((n-1)% 26 + 65)
    

Log in to reply
 

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