Given the root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) among all node values in the tree.
Input: root = [3,1,4,null,2], k = 1
Output: 1
Topics: trees, binary-search
Asked by: Amazon, Meta, Microsoft, Bloomberg
Time complexity: O(h + k). Space complexity: O(h).