Word Break Problem
Word Break Problem — ExecCode Medium DSA Practice
Solve the Word Break problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. The same dictionary word may be reused multiple times. Order must form the full string with no leftover characters. Return false if no valid segmentation exists.
Examples
Input s = "leetcode", wordDict = ["leet", "code"]; Output true. Input s = "applepenapple", wordDict = ["apple", "pen"]; Output true. Input s = "catsandog", wordDict = ["cats", "dog", "sand", "and", "cat"]; Output false
Constraints
1 ≤ s.length ≤ 300 1 ≤ wordDict.length ≤ 1000
Practice Word Break free on ExecCode. Browse DSA problems, topic map, and placement guides.