Merge base and overlay config
An app loads its settings from a base file and then an environment overlay, each given as a list of lines. In both files: trim the line; discard it when empty or when it begins with "#"; otherwise split at the first "=" and trim key and value. Combine the two into one dict where every overlay entry replaces the base entry with the same key, and inside a single file a repeated key keeps its final assignment. An override to an empty value still counts as an override. Return the combined dict.
Implement
apply_overrides(base: list[str], overlay: list[str]) → dict[str,str]Examples
in
[["retries=3","log_level=info"],["log_level=debug"]]out{"retries":"3","log_level":"debug"}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 10 min
solution.py
InputExpectedGot
[["retries=3","log_level=info"],["log_level=debug"]]{"retries":"3","log_level":"debug"}not run yetsample