We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents a81f33a + dbbf6be commit d56c8a4Copy full SHA for d56c8a4
WordBreak.py
@@ -0,0 +1,12 @@
1
+class Solution:
2
+ def wordBreak(self, s: str, wordDict: List[str]) -> bool:
3
+
4
+ f = [False for i in range(len(s) + 1)]
5
+ f[0] = True
6
7
+ for i in range(len(s)):
8
+ for j in range(i, len(s)):
9
+ if f[i] and s[i:j + 1] in wordDict:
10
+ f[j + 1] = True
11
12
+ return f[len(s)]
0 commit comments