2dbi
Home/Apple/Word Break
AApple·DSASDE-2Onsite – Coding 2

Word Break

Problem

Given a string s and a dictionary wordDict, return true if s can be segmented into a space-separated sequence of dictionary words.

Example

s = "applepenapple", wordDict = ["apple","pen"]
Output: true

Constraints

  • 1 ≤ s.length ≤ 300

Follow-up

Return all possible sentences (Word Break II) and discuss memoization to avoid TLE.

added 6 days ago
LeadersAccount