Problem, as an interviewer would state it:
"Write parseQueryString(qs) — the inverse of a query-string generator: convert key=value&key=value2 back into an object, correctly reconstructing a REPEATED key as an array value."
Examples:
parseQueryString("search=hello%20world&tags=js&tags=react&page=2");
// { search: "hello world", tags: ["js", "react"], page: "2" }
Clarifying questions expected:
- Should a genuinely repeated key produce an array, while a key that appears only once stays a plain string?
- Are all parsed values genuinely strings, even ones that look numeric (like "2")?
- Should a leading "?" be stripped automatically, or is the caller responsible for passing a clean string?
Code / implementation expected: Yes — real, direct proof of a full round trip: generate a query string with an array-valued key, parse it back, and confirm the array is correctly reconstructed.