Code Room
CodingMediumcod-g880
Subject ParsingLevel Mid–Senior~25 minCommon in Algorithms & data structures interviewsIndustries Software development, Technology

Question

Parse a URL query string into a dict. Strip a leading `?` if present. Split on `&` into pairs; each pair is `key=value` (split on the first `=` only) or a bare `key` with no `=` (value is the empty string). Percent-decode both keys and values (e.g. `%20` -> space). If the same key appears more than once, its value becomes a list of all occurrences in order; a single occurrence stays a plain string. Empty pairs (from `&&`) are skipped. An empty input yields an empty dict.

Implement
parse_query(qs: str) → dict
Examples
in["a=1&b=2"]out{"a":"1","b":"2"}
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.