Question
Maintain an ordered index under interleaved inserts and range queries (the operation log a B-tree leaf level would see). You are given a list of ops. Each op is either ['insert', key, value] (key is a unique int, inserting a key that already exists overwrites its value) or ['range', lo, hi] which returns the list of [key, value] pairs currently in the index with lo <= key <= hi, sorted ascending by key. Process ops in order and return the list of results, one list per 'range' op (inserts produce no output).
ordered_index_ops(ops: list[list]) → list[list][[["insert",5,"e"],["insert",2,"b"],["insert",8,"h"],["range",2,5]]]out[[[2,"b"],[5,"e"]]]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.