Word Break II

Try to solve the Word Break II problem.

Statement

You are given a string, s, and an array of strings, wordDict, representing a dictionary. Your task is to add spaces to s to break it up into a sequence of valid words from wordDict. We are required to return an array of all possible sequences of words (sentences). The order in which the sentences are listed is not significant.

Note: The same dictionary word may be reused multiple times in the segmentation.

Constraints:

  • 1≤1 \leq s.length ≤20\leq 20

  • 1≤1 \leq wordDict.length ≤1000\leq 1000

  • 1≤1 \leq wordDict[i].length ≤10\leq 10

  • s and wordDict[i] consist of only lowercase English letters.

  • All the strings of wordDict are unique.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy