Code RoomCanonicalize setting values
MediumPrep Room Coding #716

Canonicalize setting values

CodingAlgorithms & data structuresEntry–Mid~13 min

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.

0:00 of about 13 min
InputExpectedGot
[["debug=TRUE","port=0080","name=\"my app\""]]{"name":"my app","port":"80","debug":"true"}not run yetsample