**Problem Statement:**
Given the required input arguments, write an efficient algorithm to solve the **Kth Smallest in BST** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge.
**Hint / Expected Approach:**
In-order traversal (iterative) count to k
**Edge Cases to Consider:**
- (1) k = 1 (smallest)
- (2) k = n (largest)
- (3) BST with duplicates
Examples
Example 1
Input:[3,1,4,null,2], 1
Output:1
Explanation: Smallest
Example 2
Input:[5,3,6,2,4,null,null,1], 3
Output:3
Explanation: In-order: 1,2,3,4,5,6 → 3rd
Example 3
Input:[1], 1
Output:1
Explanation: Single node
Constraints
▪The number of nodes in the tree is in the range [0, 2000]
▪-1000 <= Node.val <= 1000
▪Ensure depth-first or breadth-first traversals are memory-efficient