Kth Smallest Element in a BST

Given the root of a binary search tree and an integer k, return the k-th smallest value among all node values (1-indexed). The tree is guaranteed to be a valid binary search tree with unique node values, and 1 <= k <= number of nodes.

Because an inorder traversal of a binary search tree visits values in ascending order, the answer is the k-th node visited by that traversal.

Examples
Input: [[3,1,4,null,2],1]
Output: 1
Hints
Related Problems

Kth Smallest Element in a BST

Given the `root` of a binary search tree and an integer `k`, return the `k`-th smallest value among all node values (1-indexed). The tree is guaranteed to be a valid binary search tree with unique node values, and `1 <= k <= number of nodes`.