Basic segmentation
Input
s = "leetcode", wordDict = ["leet", "code"]
Output
"leet code"
The string can be segmented into "leet" + "code"; return them joined by a space.
Full lesson preview
Determine if a string can be segmented into dictionary words and return one valid reconstruction.
Problem statement
Task
Examples
Input
s = "leetcode", wordDict = ["leet", "code"]
Output
"leet code"
The string can be segmented into "leet" + "code"; return them joined by a space.
Input format
Output format
Constraints
Samples
Input
word_break_reconstruct("applepenapple", ["apple","pen"])
Output
"apple pen apple"
One valid segmentation is "apple pen apple".