How do you expand nested placeholders in strings?
Company: Meta
Role: Data Scientist
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
Quick Answer: This intermediate-level Coding & Algorithms problem for Data Scientist roles evaluates string parsing and manipulation skills along with dependency resolution techniques such as recursion or graph traversal, cycle detection, and memoization.
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ({'X':'a','Y':'b','Z':'%X% and %Y%'}, '%X% and %Z%')
Expected Output: 'a and a and b'
Explanation: Prompt example.
Input: ({'A':'%B%','B':'%A%'}, '%A%')
Expected Output: '<CYCLE:A>'
Explanation: Cycle marker.
Input: ({'A':'x'}, '%A% %M%')
Expected Output: 'x %M%'
Explanation: Missing key preserved.
Hints
- Model object-style prompts as operation streams when needed.
- Handle empty and boundary cases before the main logic.