Advertisement
hacaplus

Untitled

Dec 9th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. bedbathandbeyond
  2.  
  3. go through each character until we hit a word.
  4. if we hit the end of the string without hitting a word, it's False.
  5. if we hit a word, do this again until we hit the end without hitting a word, in which case, we add to the most-recently added substring.
  6.  
  7. b -> not a word
  8. be -> a word [be]
  9. d -> not a word
  10. ...
  11. dbathandbeyond -> not a word [be]
  12. bed -> a word [bed]
  13. b -> not a word
  14. ...
  15. bat -> a word [bed,bat]
  16. h -> not a word
  17. ...
  18. hand -> a word [bed,bat,hand]
  19. b -> not a word
  20. be -> a word [bed, bat, hand, be]
  21. y -> not a word
  22. yo -> a word [bed, bat, hand, be, yo]
  23. ..
  24. nd -> not a word
  25. yon -> a word [bed,bat,hand,be,yon]
  26. d -> not a word
  27. yond -> a word [bed,bat,hand,be,yond]
  28.  
  29. -> True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement