Word Break Python
PROGRAM TO SOLVE WORD BREAK PROBLEM
OUTPUT:
Yes Yes Yes Yes Yes No
def wordBreak(wordList, word): if word == '': return True else: wordLen = len(word) return any([(word[:i] in wordList) and wordBreak(wordList, word[i:]) for i in range(1, wordLen+1)])
Yes Yes Yes Yes Yes No
Comments
Post a Comment