PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Microsoft

Determine dictionary-based string segmentation

Last updated: Mar 29, 2026

Quick Overview

This question evaluates string segmentation competency, including understanding of dynamic programming, scalable token-matching techniques (prefix data structures and hashing), and handling large input sizes.

  • Medium
  • Microsoft
  • Coding & Algorithms
  • Software Engineer

Determine dictionary-based string segmentation

Company: Microsoft

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

You are given a string s and a set of tokens dict. Determine whether s can be segmented into a sequence of one or more tokens from dict. If segmentation is possible, return one valid segmentation; otherwise return an empty result. Discuss and implement an approach that scales to |s| up to 1e5 and |dict| up to 1e5 (consider prefix pruning via tries or hashing, and dynamic programming with early exits). Analyze time and space complexity, and explain how you would extend the solution to count the number of distinct segmentations modulo 1,000,000,007.

Quick Answer: This question evaluates string segmentation competency, including understanding of dynamic programming, scalable token-matching techniques (prefix data structures and hashing), and handling large input sizes.

Related Interview Questions

  • Return Top K Open Businesses - Microsoft (hard)
  • Implement Memory Allocation and In-Memory Records - Microsoft (medium)
  • Implement K-Means and Detect Divisible Subarrays - Microsoft (medium)
  • Sort Three Categories In Place - Microsoft (medium)
  • Retain Top K Elements - Microsoft (medium)
Microsoft logo
Microsoft
Aug 14, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
1
0

You are given a string s and a set of tokens dict. Determine whether s can be segmented into a sequence of one or more tokens from dict. If segmentation is possible, return one valid segmentation; otherwise return an empty result. Discuss and implement an approach that scales to |s| up to 1e5 and |dict| up to 1e5 (consider prefix pruning via tries or hashing, and dynamic programming with early exits). Analyze time and space complexity, and explain how you would extend the solution to count the number of distinct segmentations modulo 1,000,000,007.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

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

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

Product

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

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL 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.