Given the root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) of all the values of the nodes in the tree.
3 / \ 1 4 \ 2
Input: root = [3, 1, 4, null, 2], k = 1 Output: 1 Explanation: The in-order traversal is [1, 2, 3, 4]. The 1st smallest element is 1.
5
/ \
3 6
/ \
2 4
/
1
Input: root = [5, 3, 6, 2, 4, null, null, 1], k = 3 Output: 3 Explanation: The in-order traversal is [1, 2, 3, 4, 5, 6]. The 3rd smallest element is 3.
n.1 <= k <= n <= 10^40 <= Node.val <= 10^4root = [3, 1, 4, null, 2], k = 1