Resolve config precedence
A settings loader logs every assignment it saw as "source key=value": the source word ("default", "file", or "env"), one space, then the assignment (split that part at its first "="; values may contain spaces and "="). The entries arrive in ARBITRARY order, but precedence is fixed: env beats file, file beats default. For a given key, the winner is its highest-precedence entry; among several entries of the same source, the one appearing later in the list wins. Return a dict of each key's winning value.
Implement
effective_settings(entries: list[str]) → dict[str,str]Examples
in
[["default retries=3","env retries=5","file retries=4"]]out{"retries":"5"}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 11 min
solution.py
InputExpectedGot
[["default retries=3","env retries=5","file retries=4"]]{"retries":"5"}not run yetsample