Accepted Python solution.


  • 0
    X

    Though I think the one-line Python solution using map-reduce is better. LOL

    class Solution:
        # @param s, a string
        # @return an integer
        def titleToNumber(self, s):
            result = 0
            for char in s:
                result = result*26 + (ord(char)-ord('A')+1)
            return result

Log in to reply
 

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