Given the `root` of a binary search tree and an integer `k`, return the kth smallest value (1-indexed) among all the node values in the tree. The tree is given as a level-order array. For example, given root = [3,1,4,null,2] and k = 1, the sorted values are [1,2,3,4], so the 1st smallest is 1.
Example 1
Input: root = [3,1,4,null,2], k = 1
Output: 1
Explanation: In-order traversal gives [1,2,3,4]. The 1st smallest is 1.
Example 2
Input: root = [5,3,6,2,4,null,null,1], k = 3
Output: 3
Explanation: An in-order walk of a BST visits values in sorted order: 1, 2, 3, 4, 5, 6. The 3rd value is 3.
Example 3
Input: root = [1], k = 1
Output: 1
Explanation: The tree has one node, so the 1st smallest value is 1.
Walk the tree in-order (left, root, right) and count each node visited. The moment the count reaches k, that node's value is the answer — no need to visit the rest.
Run checks all cases above. Submit evaluates all test cases.