One line in Python


  • 0
    T

    Use the elementary function to compute it.

    class Solution(object):
        def titleToNumber(self, s):
            """
            :type s: str
            :rtype: int
            """
            return sum((ord(sub) - ord('A') + 1) * 26 ** i for i, sub in enumerate(s[::-1]))
    
    
    

Log in to reply
 

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