91. Kth Smallest Value in a BST
MediumTrees
Return the k-th smallest value (1-based) in a binary search tree.
A binary tree is passed as TreeNode objects with val, left and right. The tests write trees in level order, with null for a missing child.
Example 1
Input: root = [5, 3, 6, 2, 4, null, null, 1], k = 3 Output: 3
Constraints
1 ≤ k ≤ nodes ≤ 10⁴The tree is a valid BST with distinct values