Given the root of a binary search tree and an integer k, return the k-th smallest value among all node values in the tree (1-indexed).
Input / output
root: TreeNode (LeetCode-style level-order array, null marks a missing child), k: intint — the k-th smallest node value0 <= node value <= 100,0001 <= k <= number of nodesThe tree is a BST, so an in-order traversal visits nodes in sorted order — can you stop early instead of collecting every value first? If the BST is frequently modified and queried for the k-th smallest, how would you augment each node to answer in O(h) instead of O(n)?