171. Excel Sheet Column Number
Easy
Given a column title as appear in an Excel sheet, return its corresponding column number.
😇 Solution
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
Last updated
Was this helpful?