Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bedbathandbeyond
- go through each character until we hit a word.
- if we hit the end of the string without hitting a word, it's False.
- 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.
- b -> not a word
- be -> a word [be]
- d -> not a word
- ...
- dbathandbeyond -> not a word [be]
- bed -> a word [bed]
- b -> not a word
- ...
- bat -> a word [bed,bat]
- h -> not a word
- ...
- hand -> a word [bed,bat,hand]
- b -> not a word
- be -> a word [bed, bat, hand, be]
- y -> not a word
- yo -> a word [bed, bat, hand, be, yo]
- ..
- nd -> not a word
- yon -> a word [bed,bat,hand,be,yon]
- d -> not a word
- yond -> a word [bed,bat,hand,be,yond]
- -> True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement