New
ML System Design & SQL tracks just landed
See what's new
×
Question Bank
Pricing
Blog
Forum
HOT
Referral
Description
Solution
Discussion
Submissions
Ask AI
Question Bank
Google
Coding Question
AI Insights
Quick Summary
Segment an input string into tokens using a provided dictionary of key-value pairs.
Apply a greedy strategy that always selects the longest matching prefix at each step.
Unmatched characters are preserved and emitted as individual literal tokens.
What This Tests
Trie construction and efficient prefix matching
Greedy algorithm design and state management
Linear pass string segmentation
Handling overlapping or nested dictionary keys
Common Patterns
Trie
Greedy
Collapse
Hint 1
Hint 2
What Interviewers May Ask Next
Accepted
3.2k
/8.7k
Acceptance Rate
36.5%
Ask AI Assistant
Ask AI Assistant
Ask me anything about this coding question!
Qwen
Qwen3.6-Flash
0/2000
Auto
Debug
Run
Submit
Test Cases
Input
text =
dictionary =
Output
Expected