B-tree leaf insert and range
Your task
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).
Examples
ordered_index_ops(ops: list[list]) -> list[list]Example 1
Input
ordered_index_ops([["insert", 5, "e"], ["insert", 2, "b"], ["insert", 8, "h"], ["range", 2, 5]])Output
[[[2, "b"], [5, "e"]]]