URL Query-String Parser
Asked at Airbnb
Reported by the problem's creator, not verified
You are parsing the query string of a URL into a map. The query string is everything after the first ?. It is a list of parameters separated by &, and each parameter is either key=value or just key.
Write parse_query(url).
Examples
Example 1
Input: url =
?a=b&c=dOutput:
{"a":"b","c":"d"}Explanation: Both keys appear once, so each maps to a plain string.
Example 2
Input: url =
?sd&a=b&a=c&a=d&sdOutput:
{"sd":[true,true],"a":["b","c","d"]}Explanation:
sdhas no=, so its value istrue.aappears three times, so its values are collected in order:["b", "c", "d"].sdappears twice with no value each time, giving[true, true].
Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.