LSM run merging
An LSM engine flushes a memtable and several on-disk SSTables, each given to you as a list of [key, value] pairs already sorted ascending by key. Runs are ordered oldest-first; the LAST run in the input is the newest. Merge them into a single sorted run where, for any key present in multiple runs, the value from the newest run wins. Return the merged list of [key, value] pairs sorted ascending by key. Keys are strings; total pairs across runs <= 10^5.
Implement
lsm_merge(runs: list[list[list]]) → list[list]Examples
in
[[[["a",1],["c",3]],[["b",2],["c",9]]]]out[["a",1],["b",2],["c",9]]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 30 min
solution.py
InputExpectedGot
[[[["a",1],["c",3]],[["b",2],["c",9]]]][["a",1],["b",2],["c",9]]not run yetsample