Skip to content

Instantly share code, notes, and snippets.

@munguial
Created August 10, 2020 21:25
Show Gist options
  • Save munguial/0d122ac059fbc1435a367fa82b65aada to your computer and use it in GitHub Desktop.
Save munguial/0d122ac059fbc1435a367fa82b65aada to your computer and use it in GitHub Desktop.
August - Day 10 - Excel Sheet Column Number
# https://leetcode.com/explore/featured/card/august-leetcoding-challenge/550/week-2-august-8th-august-14th/3419/
class Solution:
def titleToNumber(self, s: str) -> int:
res = 0
power = 0
for i in reversed(range(len(s))):
res += int(ord(s[i]) - ord('A') + 1) * (26**power)
power += 1
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment