My simple recursive Python solution


  • 2
    B
    class Solution:
        # @return a string
        def convertToTitle(self, num):
            alph = ''.join(map(chr, range(65, 91)))
            return (self.convertToTitle((num-1)/len(alph)) if num>len(alph) else '' )+alph[(num-1)%len(alph)]

Log in to reply
 

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