Word Break Problem

Given a dictionary of words and an input string, tell whether the input string can be segmented into dictionary words.

Statement

We’re given a dictionary of words and an input string. Find out whether the input string can be completely segmented into the words of a given dictionary. Input string and the dictionary words will not contain spaces.

Examples

The following two examples elaborate this problem further:

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.