You are given a valid binary search tree and an integer k. Return the k-th smallest value among all node values (with k = 1 meaning the smallest).
Input format
One line: the binary tree as a level-order array.
The tree is encoded on ONE line as a space-separated level-order (breadth-first) array. The token null marks a missing child; the children of a null are omitted from the array. An empty tree is written as the single token null.
The next line: an integer k.
Output format
A single integer: the k-th smallest value in the tree.
Constraints
- The tree has between 1 and 1000 nodes.
- All node values are distinct integers with absolute value at most 1000000.
- The tree is a valid binary search tree.
- 1 <= k <= number of nodes.