Sharing my Python solution with O(log(n)) complexity:


  • 0
    F
    class Solution(object):
        def titleToNumber(self, s):
            num=0
            i=0
            while (i<len(s)):
                num+=26**(len(s)-i-1)*(ord(s[i])-64)
                i+=1
            return(num)
                
    

Log in to reply
 

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