Back to Google
Coding rounds
Google coding rounds
5 timed coding challenges drawn from real loops. Submit a solution to see your test pass rate and AI feedback.
←All coding rounds
advanced 45:00+120 XP
Word Break
Given a string `s` and a dictionary `wordDict`, return true if `s` can be segmented into a space-separated sequence of one or more dictionary words. Words may be reused. Use dynamic programming over prefixes (O(n²) with a set).
Examples
leet + code
in: s="leetcode", wordDict=["leet","code"]
out: true
reuse apple
in: s="applepenapple", wordDict=["apple","pen"]
out: true
javascript
Loading editor...