Return the kth smallest node value in a strict binary search tree, counting k from one.
Example 1
Argument 1 tree: level-order input; omitted children are null.root = [5,3,7,2,4,6,8]
k = 4
5
Explanation
Inorder is 2,3,4,5,6,7,8, making the fourth value 5.
Example 2
Argument 1 tree: level-order input; omitted children are null.Explanation
The left child 1 is the smallest value.
Example 3
Argument 1 tree: level-order input; omitted children are null.Explanation
The sole node is the first smallest.
Constraints
- 1 <= k <= number of nodes <= 10000
Function contractkthSmallestArguments: tree, json