Given a non-empty string s
and a list word_list
containing a list of non-empty words, determine if s
can be segmented into a space-separated sequence of one or more dictionary words. You may assume the word_list
does not contain duplicates, but each word can be used more than once.
For example, given:
s = 'whataniceday'
word_list = ['a', 'what', 'an', 'nice', 'day']
Return True
, because 'whataniceday'
can be segmented as 'what a nice day'
.