one line in python!


  • 0
    R
    class Solution(object):
        def titleToNumber(self, s):
            """
            :type s: str
            :rtype: int
            """
            return 0 if s == '' else (self.titleToNumber(s[:-1]) * 26 + ord(s[-1]) - ord('A') + 1)
    

Log in to reply
 

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