python3 solution


  • 0
    H

    My python3 solution by using ascii code.

    class Solution:
        def titleToNumber(self, s):
            """
            :type s: str
            :rtype: int
            """
            ctr = len(s)-1
            n = 0
            for c in s:
                n += (ord(c)-64)*(26**ctr)
                ctr-=1
            return n
    

Log in to reply
 

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