simple Python solution


  • 0
    Y
    class Solution(object):
        def titleToNumber(self, s):
            """
            :type s: str
            :rtype: int
            """
            l=len(s)
            r=0
            for c in s:
                r=r+(ord(c)-ord('A')+1)*26**(l-1)
                l=l-1    
            return r
    

Log in to reply
 

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