Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. def wordBreak(self, s, wordDict):
  2. queue = [0]
  3. dictionary_set = set(wordDict)
  4. for left in queue:
  5. for right in range(left,len(s)):
  6. if s[left:right+1] in dictionary_set:
  7. if right == len(s)-1:
  8. return True
  9. queue.append(right+1)
  10. return False
  11.  
  12. s = 'aab'
  13. wordDict = ['a','aa','aaa']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement