← Zillow Interview Insights

Zillow·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
Apr 2026

Summary

Zillow ML Engineer interview with a string parsing problem that looks deceptively simple. One question, linear scan, but the follow-ups about streaming and production invariants are where it gets interesting.

Questions Asked (1)

Q1

Implement a function that replaces placeholders in a string with values from a dictionary. Placeholders are delimited by percent signs, e.g. %key%, and if a key is missing from the dictionary the function should report an error. Aim for linear time complexity.

Algorithms & Data StructuresTechnical Trade-offsSystem Design
Author's notes

Seemed straightforward at first and I jumped into code before thinking through the error case, which bit me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the placeholder syntax and error handling requirements, then design a single-pass algorithm that scans the string and builds the output, using a dictionary for O(1) key lookups. Discuss edge cases like nested or malformed placeholders and how to report missing keys, and analyze time and space complexity to ensure linear time.

Pro tip: Mention that you would use a compiled regex with a callback for a clean, linear-time solution, but also be prepared to implement a manual scanner if the interviewer wants to see low-level string manipulation. This shows you understand both readability and performance trade-offs.

1. Clarify requirements and edge cases

Ask about placeholder syntax (e.g., can keys contain percent signs?), error handling (exception vs. error message), and whether the input can have malformed placeholders. Confirm that the function should run in O(n) time.

2. Choose an approach

Decide between a regex-based solution (e.g., re.sub with a callback) and a manual scanner. Explain that both can achieve linear time, but regex is more concise while manual scanning gives more control.

3. Implement the core logic

Write code that scans the string, identifies placeholders, looks up keys in the dictionary, and builds the output. For missing keys, raise an exception or return an error as specified.

4. Handle edge cases and errors

Test with empty string, no placeholders, missing keys, adjacent placeholders, and placeholders at the start/end. Ensure malformed placeholders (e.g., unmatched percent signs) are handled gracefully.

5. Analyze complexity and discuss trade-offs

State that the algorithm is O(n) time and O(n) space for the output. Discuss potential improvements like streaming output or in-place modification if the string is mutable.

Key Points to Mention

  • Linear time complexity: single pass through the string with O(1) dictionary lookups.
  • Error handling: raise a KeyError or custom exception for missing keys, and decide on behavior for malformed placeholders.
  • Regex approach: use re.sub with a pattern like %(\w+)% and a callback that checks the dictionary.
  • Manual scanner: iterate character by character, track placeholder boundaries, and build the result.
  • Edge cases: empty string, no placeholders, missing keys, adjacent placeholders, and placeholders at string boundaries.
  • Trade-offs: regex is concise but may be slower for very large strings; manual scanning is more verbose but can be optimized.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.