Inner join tables
Implement an inner join of two tables represented as lists of dicts. 'left' rows and 'right' rows are joined on a shared key field name 'key'. For each matching pair, produce a merged dict containing all keys from the left row plus all non-'key' fields from the right row; if a non-'key' field name collides, the right value wins. Return the joined rows ordered first by the order the matching left row appears, then by the order the matching right row appears. Either table may be empty.
Implement
inner_join(left: list[dict], right: list[dict]) → list[dict]Examples
in
[[{"key":1,"name":"a"},{"key":2,"name":"b"}],[{"age":30,"key":1},{"age":40,"key":3}]]out[{"age":30,"key":1,"name":"a"}]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 25 min
solution.py
InputExpectedGot
[[{"key":1,"name":"a"},{"key":2,"name":"b"}],[{"age":30,"key":1},{"age":40,"key":3}]][{"age":30,"key":1,"name":"a"}]not run yetsample