'''
keys: 
Solutions:
Similar: 
T:
S:
'''
from typing import List


class Solution:
    # idea: number of chars in s reprenseting how many times you should
    # multiply 26
    # T: O(N), S: O(1)
    def titleToNumber(self, s: str) -> int:
        res = 0
        n = len(s)
        for i in range(n):
            res = res * 26
            res += (ord(s[i]) - ord('A') + 1)
        return res
    
    
    def titleToNumber1(self, s: str) -> int:
        result = 0
        
        # Decimal 65 in ASCII corresponds to char 'A'
        alpha_map = {chr(i + 65): i + 1 for i in range(26)}

        n = len(s)
        for i in range(n):
            cur_char = s[n - 1 - i]
            result += (alpha_map[cur_char] * (26 ** i))
        return result