Question
Compact an LSM key-value log by dropping tombstones. You are given a list of records in chronological order; each is [key, value] for a write, or [key, null] (a tombstone marking a delete) — in JSON null is None. For each key, only its LAST record matters. After applying last-writer-wins, a key whose final record is a tombstone is fully removed (its tombstone is dropped during compaction, not retained). Return the compacted live data as a list of [key, value] pairs sorted ascending by key, containing only keys whose final state is a live value. Keys are strings; <= 10^5 records.
compact_tombstones(records: list[list]) → list[list][[["a",1],["b",2],["a",null]]]out[["b",2]]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.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.