Determine if a string can be segmented
Company: TikTok
Role: Machine Learning Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates a candidate's understanding of dynamic programming and string-processing skills, along with algorithmic complexity analysis for segmentation problems.
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ('leetcode', ['leet','code'])
Expected Output: True
Explanation: Prompt true example.
Input: ('catsandog', ['cats','dog','sand','and','cat'])
Expected Output: False
Explanation: Prompt false example.
Input: ('aaaaaaa', ['aaaa','aaa'])
Expected Output: True
Explanation: Reusable words.
Hints
- Model object-style prompts as operation streams when needed.
- Handle empty and boundary cases before the main logic.