Python simple 60ms solution


  • 0
    Y
    class Solution(object):
        def titleToNumber(self, s):
            res = 0
            length = len(s)
    
            for i, c in enumerate(s):
                res += (ord(c) - 64) * 26 ** (length - i - 1)
            return res

Log in to reply
 

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