Tap here to switch tabs
Problem
Ask
Submissions

Problem: Word Break II

hard
40 min
Explore dynamic programming techniques to break a string into all possible sequences of valid words from a given dictionary. This lesson helps you understand problem constraints, practice solutions, and implement efficient algorithms for Word Break II.

Statement

You are given a string, s, and an array of strings, word_dict, representing a dictionary. Your task is to add spaces to s to break it up into a sequence of valid words from word_dict. 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:

  • 11 \leq s.length 20\leq 20

  • 11 \leq word_dict.length 1000\leq 1000

  • 11 \leq word_dict[i].length 10\leq 10

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

  • All the strings of word_dict are unique.

Tap here to switch tabs
Problem
Ask
Submissions

Problem: Word Break II

hard
40 min
Explore dynamic programming techniques to break a string into all possible sequences of valid words from a given dictionary. This lesson helps you understand problem constraints, practice solutions, and implement efficient algorithms for Word Break II.

Statement

You are given a string, s, and an array of strings, word_dict, representing a dictionary. Your task is to add spaces to s to break it up into a sequence of valid words from word_dict. 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:

  • 11 \leq s.length 20\leq 20

  • 11 \leq word_dict.length 1000\leq 1000

  • 11 \leq word_dict[i].length 10\leq 10

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

  • All the strings of word_dict are unique.