class Solution:
def letterCombinations(self, digits: str) -> List[str]:
answer = [""]
numbers = ["","","abc","def","ghi","jkl","mno", "pqrs","tuv","wxyz"]
for i in list(map(int, digits)) :
temp = []
for j in numbers[i] :
for k in answer :
temp.append(k+j)
answer = temp
return answer
문제정리
Like a phone keypad, each digit is mapped to a set of letters. Given a string of digits from 2 to 9 inclusive, return all possible letter combinations in any order.
풀이과정
Use a hash map to map each digit to its letters, and build new combinations from the results of the previous step.
Use a hash map to map each digit to its letters, and build new combinations from the results of the previous step.
풀이 후
At first, I wondered why this problem was categorized under Hash Table . After solving it, I realized that a hash map is useful for mapping each digit to its corresponding letters on the phone keypad