Prompt: Given the root of a binary search tree, and an integer k, return the kth (1-indexed) smallest element in the tree.
Input: root = [3,1,4,null,2], k = 1
Output: 1
Input: root = [5,3,6,2,4,null,null,1], k = 3
Output: 3
Solution: We can recursively traverse the binary tree on all left subtree and then right subtree. At each node, we can return the ordered list in the form of left subtree result + current node value + right subtree result. At the end of the traversal, we will have a list that is ordered and we can just index into the list. The runtime for this solution is O(log n) since we can stop traversing to the right subtrees once we have at least k number of elements in the list.