Skip to interview prep
Apexed

80. Word Break

MediumDynamic programming

Return true if s can be split into a sequence of words from words (words may be reused).

Example 1

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

Constraints

  • 1 ≤ s.length ≤ 300

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 4 hidden and sample tests.

Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.

Word Break — coding interview practice — Apexed