We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ed12c69 + 72a4ad4 commit bf14e35Copy full SHA for bf14e35
171. Excel Sheet Column Number/171. Excel Sheet Column Number.py
@@ -26,8 +26,7 @@
26
"""
27
class Solution:
28
def titleToNumber(self, s: str) -> int:
29
- temp = list(reversed(list(s)))
30
- res = 0
31
- for i,char in enumerate(temp):
32
- res += (ord(char) - ord('A') +1) * (26**i)
33
- return res
+ result = 0
+ for i,char in enumerate(s[::-1]):
+ result += (ord(char) - ord('A') + 1 ) * (26**i)
+ return result
0 commit comments