Excel Sheet Column Number

Problem Id: 171 Difficulty: Easy


Intuition

Solution


class Solution:
    def titleToNumber(self, s):
        """
        :type s: str
        :rtype: int
        """
        result = 0
        for c in s:
            result = result * 26
            result += ord(c) - ord('A') + 1
        return result