Kth Smallest Element in a BST

Try to solve the Kth Smallest Element in a BST problem.

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.
  • 1≤k≤n≤5001 \leq k \leq n \leq 500
  • 0≤0 \leq Node.data ≤104\leq 10^4

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy