Code Room
CodingMediumcod-g1510
Subject Config parsingLevel Entry–Mid~13 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

A dotfiles cleaner canonicalizes raw setting values. Input lines are "key=value"; split at the first "=", trim key and value, later duplicates win. Then rewrite each value by the FIRST rule that applies: (1) if it equals "true" or "false" ignoring case, use the lowercase word; (2) if it is an optional "-" followed only by digits (at least one), remove leading zeros — keep a single "0", and "-0", "-000" become "0"; (3) if it starts and ends with a double quote and is at least 2 characters, drop just those two quotes, keeping the inside verbatim; (4) otherwise keep it unchanged. Return the dict of rewritten values.

Implement
normalize_values(lines: list[str]) → dict[str,str]
Examples
in[["debug=TRUE","port=0080","name=\"my app\""]]out{"name":"my app","port":"80","debug":"true"}
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.