PracHub
QuestionsLearningGuidesInterview Prep
|Home/Coding & Algorithms/Amazon

Return all valid word-break sentences

Last updated: May 15, 2026

Quick Overview

This question evaluates skills in string processing, recursive search/backtracking, enumeration of all valid segmentations, and algorithmic complexity reasoning for generating multiple solutions.

  • hard
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Return all valid word-break sentences

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

Given a string `s` and a dictionary of strings `wordDict`, insert spaces into `s` to form a sentence such that every token is in `wordDict`. Return **all possible sentences** that can be formed. Words from the dictionary may be reused multiple times. Constraints/notes: - Output sentences should preserve the original character order. - If no valid segmentation exists, return an empty list.

Quick Answer: This question evaluates skills in string processing, recursive search/backtracking, enumeration of all valid segmentations, and algorithmic complexity reasoning for generating multiple solutions.

Related Interview Questions

  • Compute Edit Distance - Amazon (medium)
  • Minimize Replacements So Equal Product Values Are Contiguous - Amazon (hard)
  • Find a Maximum-Sum Window in a Sparse Array - Amazon (hard)
  • Add One Source to Minimize Grid Inconvenience - Amazon (medium)
  • Implement a Half-Open Interval Range Module - Amazon (hard)
|Home/Coding & Algorithms/Amazon

Return all valid word-break sentences

Amazon logo
Amazon
Jan 15, 2026, 12:00 AM
hardSoftware EngineerTechnical ScreenCoding & Algorithms
10
0

Given a string s and a dictionary of strings wordDict, insert spaces into s to form a sentence such that every token is in wordDict.

Return all possible sentences that can be formed. Words from the dictionary may be reused multiple times.

Constraints/notes:

  • Output sentences should preserve the original character order.
  • If no valid segmentation exists, return an empty list.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Amazon•More Software Engineer•Amazon Software Engineer•Amazon Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.