| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- 715. Range Module
- 315. Count of Smaller Numbers After Self
- data science
- iterator
- 109. Convert Sorted List to Binary Search Tree
- 컴퓨터의 구조
- shiba
- 밴픽
- concurrency
- Python
- Decorator
- 운영체제
- Python Code
- Python Implementation
- Class
- Convert Sorted List to Binary Search Tree
- Regular Expression
- Protocol
- 파이썬
- 프로그래머스
- 시바견
- t1
- 43. Multiply Strings
- DWG
- kaggle
- Substring with Concatenation of All Words
- Generator
- LeetCode
- attribute
- 30. Substring with Concatenation of All Words
Archives
- Today
- Total
Scribbling
LeetCode: 140. Word Break II 본문
class Solution:
def wordBreak(self, s: str, wordDict: List[str]) -> List[str]:
self.wordDict = set(wordDict)
self.ret = []
self.dfs(s, [])
return self.ret
def dfs(self, s, path):
if not s:
self.ret.append(' '.join(path))
return
for word in self.wordDict:
k = len(word)
if s[:k] == word:
self.dfs(s[k:], path+[word])'Computer Science > Coding Test' 카테고리의 다른 글
| LeetCode: 149. Max Points on a Line (0) | 2021.11.22 |
|---|---|
| LeetCode: 143. Reorder List (0) | 2021.11.22 |
| LeetCode: 139. Word Break (0) | 2021.11.19 |
| LeetCode: 138. Copy List with Random Pointer (0) | 2021.11.16 |
| LeetCode: 295. Find Median from Data Stream (0) | 2021.11.16 |