A Python3 Solution

  • 1
    • 1000 / 1000 test cases passed.
      Status: Accepted
      Runtime: 115 ms
    class Solution:
        def titleToNumber(self, s):
            :type s: str
            :rtype: int
            if isinstance(s,str):
                l = len(s)
                if not l:
                    return 'Error: title is None'
                temp = s[::-1]
                result = 0
                for i in range(l):
                    result += (ord(temp[i])-64)*(26**i)
                return result
                return Error

Log in to reply

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