DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
medium
DP

Word Break

**Problem Statement:** Given the required input arguments, write an efficient algorithm to solve the **Word Break** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge. **Hint / Expected Approach:** dp[i] = any dp[j] where s[j..i] in dict **Edge Cases to Consider:** - (1) Empty string - (2) Word not in dict at all - (3) Overlapping words

Examples

Example 1
Input: "leetcode", ["leet","code"]
Output: true
Example 2
Input: "applepenapple", ["apple","pen"]
Output: true
Example 3
Input: "catsandog", ["cats","dog","sand","and","cat"]
Output: false

Constraints

  • ▪Input arguments are within valid ranges
  • ▪Optimize for execution speed
  • ▪Handle null/empty inputs gracefully

Watch Out For Edge Cases

  • ▪Empty string
  • ▪Word not in dict at all
  • ▪Overlapping words
Frequently Asked At
AmazonGoogleMicrosoftMetaAdobeUber