Skip to content

Commit 3ea6a68

Browse files
committed
feat: add 0271 Word Break solution
1 parent fd1c08f commit 3ea6a68

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

word-break/hyogshin.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from typing import List
2+
3+
class Solution:
4+
def wordBreak(self, s: str, wordDict: List[str]) -> bool:
5+
dp = [False] * (len(s) + 1)
6+
dp[0] = True
7+
for i in range(1, len(s) + 1):
8+
for j in range(i):
9+
if dp[j] and s[j:i] in wordDict:
10+
dp[i] = True
11+
break
12+
return dp[len(s)]
13+

0 commit comments

Comments
 (0)