BST k-th smallest

Write codeHard35 minMeta and Amazon style

Your task

Process a stream of commands on an initially empty binary search tree. ["insert", v] inserts v (duplicates allowed and go to the right subtree). ["kth", k] returns the k-th smallest value currently in the tree (1-indexed), or -1 if the tree has fewer than k elements. Return the list of answers to the "kth" commands, in order. Build the BST in insertion order without rebalancing.

Examples

bst_order_statistics(commands: list[list]) -> list[int]
Example 1
Inputbst_order_statistics([["insert", 5], ["insert", 3], ["insert", 8], ["kth", 1], ["kth", 2], ["kth", 3]])
Output[3, 5, 8]