Problem - https://www.geeksforgeeks.org/problem...
Medium - / word-break-problem
Given a string A and a dictionary of n words B, find out if A can be segmented into a space-separated sequence of dictionary words. Return 1 if it is possible to break A into sequence of dictionary words, else return 0.
Note: From the dictionary B each word can be taken any number of times and in any order.
Example 1:
Input:
n = 6
B = { "i", "like", "sam", "sung", "samsung", "mobile"}
A = "ilike"
Output:
1
Explanation:
The string can be segmented as "i like".
Example 2:
Input:
n = 6
B = { "i", "like", "sam", "sung", "samsung", "mobile"}
A = "ilikesamsung"
Output:
1
Explanation:
The string can be segmented as
"i like samsung" or "i like sam sung"