FastPrepWord Break
Problems/Word Break

Word Break

Google logoGoogle● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The earlier report gives the yes-or-no task, an example, and a memoized DFS approach. It does not give a rule for persistent updates, how matching is cleaned up, input limits, or a function signature. Our version is about 94% the same as that earlier exercise. A later recollection describes the same task with periodic-table words. It does not say whether to use names or symbols, give an element list, say how case is handled, or ask for a count. The optional variation keeps that context, while the task stays a yes-or-no word split with exact dictionary matching.

Special thanks: 🌷 A special thank you to a lovely, amazing fren for sharing a periodic-table variation of this question from October 14, 2026! ദ്ദി ˉ͈̀꒳ˉ͈́ )✧ 💚

Given a string s and an array of dictionary words wordDict, return true if s can be split into a sequence of one or more dictionary words. Otherwise, return false.

All words in wordDict are available for the entire call, and a word may be reused multiple times. Dictionary membership uses exact string equality; duplicate entries do not change the result.

Periodic-table dictionary variation

Use periodic-table entries in place of ordinary dictionary words and decide whether the input can be segmented entirely into the supplied entries. This is a vocabulary variation of the same boolean word-segmentation task, not a request to count or return every decomposition. Keep the supplied wordDict entries and exact string equality; do not assume a particular element list or silently change their case.

Function

wordBreak(s: String, wordDict: List<String>) → boolean

Examples

Example 1

s = "leetcode"wordDict = ["leet","code"]return = true

Split s as leet + code. Both pieces belong to wordDict.

Example 2

s = "catsandog"wordDict = ["cats","dog","sand","and","cat"]return = false

The prefixes cats and cat both lead to suffixes that cannot be fully segmented.

Example 3

s = "applepenapple"wordDict = ["apple","pen"]return = true

Split s as apple + pen + apple. Reusing apple is allowed.

Constraints

  • 1 <= s.length <= 300.
  • 1 <= wordDict.length <= 1000.
  • 1 <= wordDict[i].length <= 20.
  • Every dictionary entry is non-empty.

More Google Onsite Interview questions

  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Word BreakExpedia · ONSITE INTERVIEWExpedia interview questions
  • Feature Flags with Rules, Dependencies and ExposurePerplexity AI · ONSITE INTERVIEWPerplexity AI interview questions
  • JSON Path Lookup with Implicit Array WildcardsMongoDB · ONSITE INTERVIEWMongoDB interview questions
  • Maximum Bouquet ValueOracle · ONSITE INTERVIEWOracle interview questions
  • Word BreakAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Serialize and Deserialize an N-Ary TreeUber · ONSITE INTERVIEWUber interview questions
  • Reconstruct One Sentence From a DictionaryMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Word BreakMoveworks · ONSITE INTERVIEWMoveworks interview questions
  • Filesystem Hash TreeCursor · PHONE SCREEN · ONSITE INTERVIEWCursor interview questions
  • Transitive Employee Referral CountsRobinhood · ONSITE INTERVIEWRobinhood interview questions

Interview reports that mention this question

  • Google SWE Intern Interviews: 85 Experiences (Part 1 of 8)

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public boolean wordBreak(String s, List<String> wordDict) {
      // Write your code here.
    }
}
Checking account…