FastPrepWord Break
Problems/Word Break

Word Break

Expedia logoExpedia● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The task of splitting a string into dictionary words matches the linked reference at about 98%. We use lowercase words.

Given a nonempty string s and a dictionary wordDict, return whether the entire string can be split into one or more dictionary words.

A dictionary word may be reused any number of times. Every character of the string must belong to exactly one chosen word, with no gaps or overlap.

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.

Example 4

s = "codingninjas"wordDict = ["coding","ninjas"]return = true

Split the string as coding + ninjas. Both words are in the dictionary.

Constraints

  • 1 <= s.length <= 300.
  • 1 <= wordDict.length <= 1000.
  • 1 <= wordDict[i].length <= 20.
  • The string and all dictionary words contain only lowercase English letters.
  • Dictionary words are distinct.

More Expedia Onsite Interview questions

  • Scramble StringONSITE INTERVIEW · Seen Sep 2026
  • Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
  • Check Anagram Pairs Index by IndexONSITE INTERVIEW · Seen Oct 2025
  • Fresh Oranges Left After Rotting StopsONSITE INTERVIEW · Seen Oct 2025
  • Longest Increasing SubsequenceONSITE INTERVIEW · Seen Oct 2025
  • Lowest Common Ancestor with Repeated and Missing ValuesONSITE INTERVIEW · Seen Oct 2025
  • Shortest Substring with Exactly K OnesONSITE INTERVIEW · Seen Oct 2025
  • Middle Element of a Linked ListONSITE INTERVIEW · Seen Nov 2024
  • Minimum in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Sep 2024
  • Mirror Image Binary TreesONSITE INTERVIEW · Seen Sep 2024

Similar questions at other companies

  • Word BreakGoogle · ONSITE INTERVIEWGoogle 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

  • Expedia New Grad SDE Oldest Loops: 4 Experiences (Part 3 of 3)
  • Expedia New Grad SDE Earlier Loops: 5 Experiences (Part 2 of 3)

Expedia interview experiences

  • Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
  • Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
  • Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
  • Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
All Expedia interview questionsSee Expedia hiring insights
Saved
class Solution {
    public boolean wordBreak(String s, List<String> wordDict) {
      // Write your code here.
    }
}
Checking account…