Problem
You get a string s and a list of words word_dict. Return true if you can split s into a sequence of one or more words from word_dict. Otherwise, return false.
You can use a word from word_dict more than one time. All the words in word_dict are different.
Example 1
- Input:
- s = "sunflower", word_dict = ["sun","flower","flow"]
- Output:
- true
- Explanation:
"sunflower"is"sun"followed by"flower".
Example 2
- Input:
- s = "redredblue", word_dict = ["red","blue"]
- Output:
- true
- Explanation:
- The split is
"red","red"and"blue". It uses the word"red"two times.
Example 3
- Input:
- s = "carpets", word_dict = ["car","pet","carp"]
- Output:
- false
- Explanation:
- Each split leaves
"s"or"ets"at the end, andword_dictdoes not contain these strings.
Constraints
- 1 <= s.length <= 300
- 1 <= word_dict.length <= 1000
- 1 <= word_dict[i].length <= 20
- s and word_dict[i] have only lowercase English letters.
- All the strings in word_dict are different.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Word Break II
Coding · Array · Backtracking · Dynamic Programming
- Encrypt and Decrypt Strings
Coding · Array · Design · Hash Table
- Shortest Uncommon Substring in an Array
Coding · Array · Hash Table · String
- Top K Frequent Words
Coding · Array · Bucket Sort · Counting
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 5 records
Amazon
Leetcode 139. Word Break
Reported Sep 30, 2026 · 2 source reports
MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceGoogle
Leetcode 139. Word Break
Reported Mar 26, 2026 · 1 source report
JUNIOR
Source snapshot: Nov 12, 2026
View sourceMeta
Leetcode 139. Word Break
Reported May 1, 2025 · 3 source reports
MID_LEVEL, SENIOR
Source snapshot: Nov 12, 2026
View sourceMicrosoft
Leetcode 139. Word Break
Reported Sep 23, 2026 · 2 source reports
MID_LEVEL, SENIOR
Source snapshot: Nov 12, 2026
View source