SIMPLE O(n) python solution using chars


  • 1
    A
    class Solution(object):
        def titleToNumber(self, s):
            num = 0
            for c in s:
                num = num * 26 +  ( ord(c) - ord('A') + 1)
            return num

Log in to reply
 

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