Word Break Problem
Given a dictionary, you have to split a given string into meaningful words.
Example:
Case-I:
If the dictionary contain the words:
{"like", "i" , "ice" , "cream", "is"};
Input : "ilikeicecream"
Output: "i like ice cream"
Case-II:
If the dictionary contain the words:
{"like", "i" , "ice" , "cream", "is"}
Input: "ilikeeicecream"
Output: False
(There is no combination possibleout from the dictionary)
Algorithm:
We solve the problem using dynamic programming. The problem contains two parts one is detecting the words and the other one is retrieving the words.
Case-I
Case-II
C++ Implementation for word break problem
Output
need an explanation for this answer? contact us directly to get an explanation for this answer