오랜만에 리트코드를 켰다. 이제 서서히 공부를 시작해나갔으면 좋겠다.
사실 연구 하기 싫어서 리트코드 한건 안비밀...
class Solution:
def letterCombinations(self, digits: str) -> List[str]:
dictionary = {'2':'abc', '3':'def', '4':'ghi', '5':'jkl', '6':'mno', '7':'pqrs', '8':'tuv', '9':'wxyz'}
if not digits:
return []
output = ['']
for idx in digits:
output = [prev + l for prev in output for l in dictionary[idx]]
return output
'Leetcode' 카테고리의 다른 글
Leetcode 2160. Minimum Sum of Four Digit Number After Splitting Digits (0) | 2022.02.11 |
---|---|
Leetcode 532. K-diff Pairs in an Array (0) | 2022.02.10 |
Leetcode 938. Range Sum of BST (0) | 2021.12.14 |
Leetcode 26. Remove Duplicates from Sorted Array (0) | 2021.12.12 |
Leetcode 563. Binary Tree Tilt (0) | 2021.12.09 |