Easy
Last updated 4 years ago
Was this helpful?
Given a column title as appear in an Excel sheet, return its corresponding column number.
class Solution: def titleToNumber(self, s: str) -> int: ans = 0 for i in range(1,len(s)+1): ans += (26**(i-1)) * (ord(s[-i])-64) return ans