One line python use sum


  • 0
    P
    class Solution(object):
        def titleToNumber(self, s):
            """
            :type s: str
            :rtype: int
            """
            return sum((string.ascii_uppercase.index(c)+1) * 26**(i) for i,c in enumerate(s[::-1]))
    

Log in to reply
 

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