Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
798 B
3
Indexable
Never
def get_multiplied_array(ara1, ara2):
    result = []
    for i in ara1:
        for j in ara2:
            result.append(i+j)
    
    return result 


class Solution:
    
    def letterCombinations(self, digits: str) -> List[str]:
        if len(digits) == 0: return []
        digit_mapper = {
            '2': ['a', 'b', 'c'], 
            '3': ['d', 'e', 'f'], 
            '4': ['g', 'h', 'i'], 
            '5': ['j', 'k', 'l'], 
            '6': ['m', 'n', 'o'], 
            '7': ['p', 'q', 'r', 's'], 
            '8': ['t', 'u', 'v'], 
            '9': ['w', 'x', 'y', 'z'], 

        }
        result = digit_mapper[digits[-1]]
        for i in range(len(digits)-2, -1, -1): 
            result = get_multiplied_array(digit_mapper[digits[i]], result)
            
        return result