word break
1class Solution:
2 def wordBreak(self, s, words):
3 ok = [True]
4 for i in range(1, len(s)+1):
5 w = False
6 for j in range(i):
7 substring = s[j:i]
8 if ok[j] and substring in words:
9 w = True
10 break
11 ok += w,
12 return ok[-1]