← Airbnb Interview InsightsMachine Learning Engineer

Airbnb·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
May 2026

Summary

Airbnb ML engineer coding screen, one problem but it kept growing. Started easy enough and then the follow-ups stacked up fast and I wasn't totally ready for all of them.

Questions Asked (3)

Q1

Parse a URL query string into a dictionary, handling keys with no value, repeated keys, and an optional leading '?' character.

Algorithms & Data StructuresAPI & Integrations
Author's notes

The base case felt manageable.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and edge cases, then outline a step-by-step algorithm before writing code. Emphasize handling of empty values, repeated keys, and the optional leading '?' while discussing trade-offs between different data structures.

Pro tip: Proactively discuss how you would handle URL-encoded characters and edge cases like empty query strings or keys without '=', showing attention to real-world robustness. Also, mention that in Python you might use urllib.parse, but for an interview, implementing manually demonstrates deeper understanding.

1. Clarify Requirements

Ask about expected behavior for edge cases: keys with no value (e.g., '?key'), repeated keys (should values be a list or last wins?), and whether to decode URL-encoded characters.

2. Choose Data Structure

Decide whether to store repeated keys as lists or overwrite. For ML engineering, consider if order matters or if you need to preserve all values.

3. Outline Algorithm

Describe steps: remove leading '?' if present, split by '&', then for each pair split by '=' (handle missing '='), and populate the dictionary accordingly.

4. Implement and Test

Write clean code with comments, then walk through test cases: empty string, single key-value, key with no value, repeated keys, and URL-encoded values.

5. Discuss Extensions

Mention how to handle URL decoding, nested structures, or performance for large query strings, showing awareness of production concerns.

Key Points to Mention

  • Handling of keys with no value (e.g., '?key' or '?key=') — decide whether to assign None, empty string, or omit.
  • Repeated keys: choose between last-value-wins, first-value-wins, or list of values; justify based on use case.
  • Optional leading '?': strip it if present, but handle absence gracefully.
  • URL decoding: use urllib.parse.unquote or equivalent to decode percent-encoded characters.
  • Edge cases: empty query string, multiple '&' separators, keys with '=' in value, and whitespace.
  • Time and space complexity: O(n) time and O(k) space where k is number of unique keys.

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

Q2

Extend your solution to handle percent-encoded characters in keys and values, using a provided unquote() function. How do you make sure encoded delimiters like %26 or %3D don't break your parsing logic?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This is where I stumbled a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Explain that you must decode percent-encoded characters only after parsing the raw string into key-value pairs, because encoded delimiters like %26 and %3D are not actual delimiters. Emphasize that you split on literal delimiters first, then apply unquote() to each key and value separately, ensuring that encoded delimiters remain part of the data and do not affect parsing logic.

Pro tip: Mention that you would validate the unquote() function's behavior with edge cases like double-encoding or malformed sequences, and consider whether decoding should happen before or after splitting based on the specification. This shows attention to detail and robustness.

1. Clarify the parsing rules

Confirm that delimiters are literal characters (e.g., '&' and '=') and that percent-encoded sequences like %26 and %3D represent data, not delimiters. Ensure you understand the input format and the role of unquote().

2. Split on literal delimiters first

Parse the raw string by splitting on unencoded delimiters (e.g., '&' for pairs, '=' for key-value). Do not decode before splitting, as that would turn encoded delimiters into real ones and break parsing.

3. Apply unquote() to each component

After splitting, call unquote() on each key and value individually to decode percent-encoded characters. This ensures that encoded delimiters within keys or values are correctly interpreted as data.

4. Handle edge cases and errors

Consider malformed percent-encoding (e.g., incomplete sequences) and decide how to handle them (e.g., leave as-is or raise an error). Also, test with keys/values containing encoded delimiters to verify correctness.

5. Validate with examples

Walk through a concrete example, such as 'a%3Db=c%26d', showing that splitting yields ['a%3Db', 'c%26d'], and unquoting gives 'a=b' and 'c&d', preserving the intended data.

Key Points to Mention

  • Decode after splitting, not before, to avoid misinterpretation of encoded delimiters.
  • The unquote() function should be applied to each key and value separately.
  • Encoded delimiters (%26, %3D) are data and must not affect parsing logic.
  • Consider edge cases: double-encoding, malformed sequences, and empty values.
  • Test with examples where keys or values contain encoded delimiters to ensure robustness.
  • Discuss trade-offs: decoding before splitting might be simpler but incorrect; decoding after is correct but requires careful splitting.

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

Q3

How would you handle malformed query strings? Think about empty keys, trailing ampersands, multiple '=' signs in a single pair, and invalid percent-escape sequences.

Technical Trade-offsAPI & Integrations
Author's notes

Mostly a discussion, not a coding task.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the context: is this for a public API, internal service, or data pipeline? Then outline a robust parsing strategy that handles edge cases gracefully, emphasizing security, observability, and trade-offs between strictness and leniency. Conclude with how you'd test and monitor such parsing in production.

Pro tip: Mention that you'd log malformed inputs with enough context to debug but avoid logging sensitive data, and consider rate-limiting or alerting on spikes to detect abuse. This shows you think about production readiness, not just parsing logic.

1. Clarify requirements and context

Ask about the API's purpose, expected clients, and tolerance for errors. Determine if the service should be strict (reject malformed) or lenient (best-effort parse).

2. Define malformed cases and desired behavior

Enumerate cases like empty keys, trailing ampersands, multiple '=' signs, and invalid percent-escapes. Decide whether to ignore, sanitize, or reject each case based on security and usability.

3. Choose a parsing strategy

Use a well-tested library (e.g., Python's urllib.parse) but wrap it with custom validation. For multiple '=', split on first '=' only; for invalid escapes, either decode leniently or reject with a 400 error.

4. Implement error handling and observability

Log malformed inputs with request IDs, but redact sensitive data. Emit metrics on malformed rates and set up alerts for anomalies.

5. Test and iterate

Write unit tests for all edge cases, including fuzzing. Consider integration tests with real clients. Be prepared to adjust based on production feedback.

Key Points to Mention

  • Use a standard library for parsing but add custom validation for edge cases.
  • Decide on strict vs. lenient parsing based on API contract and security.
  • Handle multiple '=' by splitting on the first occurrence only.
  • For invalid percent-escapes, either reject with 400 or decode leniently (e.g., treat '%' as literal).
  • Log malformed inputs for debugging but avoid logging sensitive data.
  • Monitor malformed request rates to detect abuse or client bugs.

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