← Airbnb Interview Insights

Airbnb·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Airbnb software engineer interview with a URL query string parsing problem. Pretty involved for a single coding question, lots of edge cases to think through.

Questions Asked (1)

Q1

Write a function that parses the query string portion of a GET URL and returns a map of keys to their parsed values. Keys can repeat (combine into a list), values can be integers, strings, or booleans. Quoted strings should be unquoted. Segments starting with '!' and no '=' are boolean flags set to true.

Algorithms & Data StructuresAPI & IntegrationsTechnical Trade-offs
Author's notes

More edge cases than I expected going in.

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 parsing algorithm before writing code. Focus on splitting the query string into segments, parsing each segment into key-value pairs, and aggregating repeated keys into lists while handling type conversions and boolean flags.

Pro tip: Demonstrate production awareness by discussing how you would handle malformed input, URL encoding, and performance for large query strings, and mention that you would write unit tests for edge cases like empty values, repeated keys, and quoted strings with special characters.

1. Clarify requirements and edge cases

Ask questions to confirm the expected behavior for ambiguous cases such as empty values, keys without values, URL-encoded characters, and values that look like numbers but should remain strings. This ensures you build the right solution.

2. Design the parsing algorithm

Outline a plan: split the query string by '&', then for each segment, check if it starts with '!' and has no '=' (boolean flag), otherwise split on the first '=' into key and value. Parse the value into int, bool, or string, unquoting if necessary.

3. Implement aggregation logic

Use a map to accumulate values. If a key is seen again, convert the existing value into a list and append the new value. Ensure that boolean flags are also aggregated correctly if repeated.

4. Handle type conversion and unquoting

For each value, attempt to parse as integer, then boolean ('true'/'false'), otherwise treat as string. If the value is enclosed in quotes, remove the quotes and treat as string without further type conversion.

5. Test and discuss trade-offs

Walk through test cases including repeated keys, mixed types, quoted strings, and boolean flags. Discuss trade-offs such as using a single pass vs. multiple passes, and how to handle URL decoding.

Key Points to Mention

  • Splitting the query string on '&' and then on the first '=' to separate keys and values.
  • Detecting boolean flags: segments starting with '!' and containing no '='.
  • Type inference: parsing integers, booleans, and strings, with quoted strings taking precedence.
  • Aggregating repeated keys into a list, ensuring the data structure supports both single values and lists.
  • Handling edge cases: empty values, missing keys, URL-encoded characters, and malformed segments.
  • Considering performance and scalability for large query strings, and suggesting unit tests for correctness.

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