← Back to all problems
Medium

Word Break

Updated Feb 24, 2026

Problem

Return true if s can be segmented into dictionary words.

Constraints

1 <= s.length <= 300

Examples

Example 1

Input: {"s": "leetcode", "wordDict": ["leet", "code"]}
Output: true

Function Signature

def wordBreak(self, s: str, wordDict: list[str]) -> bool

How to Submit

Implement a Solution class with a wordBreak method.

Your method will be called with the input parameters and should return the answer.