My Python Solution


  • 0
    Z
    class Solution(object):
        def titleToNumber(self, s):
            """
            :type s: str
            :rtype: int
            """
            l = list(s)
            return self.solv(l,0)
        
        def solv(self,l,sum):
            sum = sum + pow(26,len(l)-1) * (ord(l[0]) % ord('A') + 1)
            del l[0]
            if len(l):
                sum = self.solv(l,sum)
            return sum
    

Log in to reply
 

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