FastPrepWord Break with a Reusable Dictionary
Problems/Word Break with a Reusable Dictionary

Word Break with a Reusable Dictionary

Meta logoMeta● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Meta onsite interview. The original report gives the yes or no word break with a word set you can reuse. It leaves out empty input, the reuse rules, examples, limits, and the function signature. We use the usual rules. Our version is about 94% the same as the reported question.

Given a string s and a set of nonempty dictionary words, return whether s can be segmented into a sequence of one or more dictionary words.

Each dictionary word may be reused any number of times. The segmentation must cover the entire string in order. The empty string is segmentable using zero words.

Function

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

Examples

Example 1

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

Split the string as leet | code.

Example 2

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

The word apple is reused in apple | pen | apple.

Example 3

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

Every possible prefix decomposition leaves a suffix that is not in the dictionary.

Constraints

  • 0 <= s.length <= 5000.
  • 0 <= dictionary.length <= 5000.
  • 1 <= dictionary[i].length <= 100.
  • s and every dictionary word contain only lowercase English letters.
  • Dictionary words are unique.

More Meta Onsite Interview questions

  • Multi-Head Attention Forward PassPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Run-Length Encoded Vector Dot ProductPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Mutual-Friend RecommendationsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Deterministic K-Means AssignmentsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Linear Layer Forward and Backward PassesONSITE INTERVIEW · Seen Sep 2026
  • Reservoir Sampling with Recorded DrawsONSITE INTERVIEW · Seen Sep 2026
  • Stochastic Gradient Descent with MomentumONSITE INTERVIEW · Seen Sep 2026
  • Top K Largest Values with a HeapONSITE INTERVIEW · Seen Sep 2026
  • Partition a Card Deck into FifteensONSITE INTERVIEW · Seen Sep 2026
  • Insert into a Sorted Circular ListONSITE INTERVIEW · Seen Aug 2026

Similar questions at other companies

  • Word BreakAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Word BreakMoveworks · ONSITE INTERVIEW
  • Word BreakBloomberg LP · PHONE SCREEN · ONSITE INTERVIEW
  • Longest String ChainVisa · OA
  • Minimum Dictionary SegmentsGoogle · PHONE SCREEN
  • Count Equal-Frequency SubsequencesExpedia · OA
  • Longest String ChainLinkedIn · OA
  • Can the Text Split Into Dictionary WordsAdobe · PHONE SCREEN
  • Longest Common URL History RunDatadog · PHONE SCREEN
  • Word Break IIWex · PHONE SCREEN

Interview reports that mention this question

  • Meta Software Engineer Onsite Questions: 3 Experiences

Meta interview experiences

  • Meta PhD SWE Intern AI Coding Phone Screen: 1 Experience
  • Meta Business Support Engineer Phone Screen: 1 Experience
  • Meta AI Native Engineer OA and Onsite: 1 Experience
  • Meta AI-Native Coding Interview: 3 Experiences
  • Meta Production Engineer Intern Questions: 6 Experiences
See Meta hiring insights
Saved
class Solution {
    public boolean wordBreak(String s, List<String> dictionary) {
        // Write your code here.
    }
}
Checking account…