| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Decorator
- kaggle
- Python Code
- t1
- 715. Range Module
- DWG
- 프로그래머스
- 43. Multiply Strings
- 시바견
- Python Implementation
- attribute
- Python
- Class
- 운영체제
- shiba
- 30. Substring with Concatenation of All Words
- LeetCode
- concurrency
- Substring with Concatenation of All Words
- 밴픽
- Convert Sorted List to Binary Search Tree
- 컴퓨터의 구조
- Protocol
- Generator
- data science
- Regular Expression
- iterator
- 315. Count of Smaller Numbers After Self
- 109. Convert Sorted List to Binary Search Tree
- 파이썬
Archives
- Today
- Total
Scribbling
LeetCode: 17. Letter Combinations of a Phone Number 본문
Computer Science/Coding Test
LeetCode: 17. Letter Combinations of a Phone Number
focalpoint 2021. 8. 21. 15:10class Solution:
def letterCombinations(self, digits: str) -> List[str]:
if not digits:
return []
ret_list = []
x = [
[],
[],
['a', 'b', 'c'],
['d', 'e', 'f'],
['g', 'h', 'i'],
['j', 'k', 'l'],
['m', 'n', 'o'],
['p', 'q', 'r', 's'],
['t', 'u', 'v'],
['w', 'x', 'y', 'z'],
]
def save_comb(digits, string):
if not digits:
ret_list.append(string)
return
char_list = x[int(digits[0])]
for char in char_list:
save_comb(digits[1:], string+char)
save_comb(digits, '')
return ret_list'Computer Science > Coding Test' 카테고리의 다른 글
| LeetCode: 19. Remove Nth Node From End of List (0) | 2021.08.22 |
|---|---|
| LeetCode: 18. 4Sum (0) | 2021.08.22 |
| LeetCode: 16. 3Sum Closest (0) | 2021.08.21 |
| LeetCode: 15. 3Sum (0) | 2021.08.19 |
| LeetCode: 11. Container With Most Water (1) | 2021.08.17 |