Very readable Python solution

  • 0
    class Solution(object):
        def titleToNumber(self, s):
            :type s: str
            :rtype: int
            numbers = range(1, 27)
            d = dict(zip(letters, numbers))
            res = 0
            for c in s:
                res *= 26
                res += d[c]
            return res

Log in to reply

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