...

/

Solution: Kth Smallest Element in a BST

Solution: Kth Smallest Element in a BST

Let's solve the Kth Smallest Element in a BST problem using the Tree Depth-First Search pattern.

Statement

Given the root node of a binary search tree and an integer value k, return the kthk^{th} smallest value in the tree.

Constraints:

  • The number of nodes in the tree is nn.
  • 1kn5001 \leq k \leq n \leq 500
...