HardPro challengePythonJavaScriptTypeScript
Deep Merge Configs
BackendObjectsConfig
Deep-merge an array of config objects (left to right).
Rules:
- Plain objects merge recursively.
- Arrays in later configs replace earlier (no concatenation).
nullin a later config explicitly removes the key from the result.- Other values overwrite.
solve([{ a: { b: 1 }, list: [1] }, { a: { c: 2 }, list: [2, 3] }])
→ { a: { b: 1, c: 2 }, list: [2, 3] }.
Sample tests
Test #1Disjoint keys
Input: [[{"a":1},{"b":2}]]
Output: {"a":1,"b":2}
Test #2Deep merge
Input: [[{"a":{"b":1}},{"a":{"c":2}}]]
Output: {"a":{"b":1,"c":2}}
Test #3Array replaces
Input: [[{"list":[1,2]},{"list":[3]}]]
Output: {"list":[3]}
Test #4Null deletes key
Input: [[{"a":1,"b":2},{"a":null}]]
Output: {"b":2}
Test #5Null deletes nested
Input: [[{"a":{"b":1}},{"a":{"b":null,"c":3}}]]
Output: {"a":{"c":3}}