일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 109. Convert Sorted List to Binary Search Tree
- 30. Substring with Concatenation of All Words
- concurrency
- 프로그래머스
- Python Code
- iterator
- Generator
- Protocol
- Class
- Python Implementation
- shiba
- 43. Multiply Strings
- DWG
- 운영체제
- attribute
- t1
- Regular Expression
- 밴픽
- LeetCode
- kaggle
- 715. Range Module
- data science
- 시바견
- 컴퓨터의 구조
- Decorator
- 파이썬
- Convert Sorted List to Binary Search Tree
- Substring with Concatenation of All Words
- 315. Count of Smaller Numbers After Self
- Python
Archives
- Today
- Total
목록139. Word Break (1)
Scribbling
LeetCode: 139. Word Break
단어를 분해하거나 단어에서 단어를 찾는 문제를 다룰 때 가장 먼저 해볼만한 접근은, 분해 대상 단어를 한글짜 단위로 확인해가면서 완전탐색하는 것이다. 아래는 완전 탐색 코드이다. class Solution: def wordBreak(self, s: str, wordDict: List[str]) -> bool: self.wordDict = set(wordDict) return self.dfs(s) def dfs(self, s): if not s: return True for i in range(1, len(s)+1): if s[:i] in self.wordDict: if self.dfs(s[i:]): return True return False 제출해보면...? 타임 아웃이다. 생각해보면 dfs의 변수로 ..
Computer Science/Coding Test
2021. 11. 19. 19:17