120: Word break

Given a string and dictionary, check if the given string can be segmented into a space-separated sequence of dictionary words

 

Example 1

Input:   word = "ilikeenterprisecraftsmanship", dictionary = ["i", "enterprise", "like", "craftsmanship", "bist"] 

Output:  true

Explanation: can be segmented into i like enterprise craftsmanship

Example 2

Input:   word = "ilikemango", dictionary = ["i", "enterprise", "like", "craftsmanship", "bist"] 

Output:  false

Explanation: the dictionary does not have mango

Difficulty:Medium
Topic:Dynamic programming
Problem #:120