Code RoomParse query string
MediumPrep Room Coding #1248

Parse query string

CodingDatabases & SQLAlgorithms & data structuresMid–Senior~25 min

Parse a URL query string into a dict. The string is a '&'-separated list of 'key=value' pairs. Apply percent-decoding to both keys and values: '%XX' is a hex byte (decode as a single ASCII character), and '+' decodes to a space. A pair with no '=' has an empty-string value. If a key repeats, the LAST occurrence wins. An empty input yields an empty dict. Return the resulting dict.

Implement
parse_query(qs: str) → dict[str,str]
Examples
in["name=John+Doe&city=NYC"]out{"city":"NYC","name":"John Doe"}
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.

0:00 of about 25 min
InputExpectedGot
["name=John+Doe&city=NYC"]{"city":"NYC","name":"John Doe"}not run yetsample