Tap here to switch tabs
Problem
Submissions

Problem: Kth Smallest Element in a BST

Kth Smallest Element in a BST asks you to find the value with the requested rank among all values in a binary search tree, given its root and an integer k.

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
⋮
Tap here to switch tabs
Problem
Submissions

Problem: Kth Smallest Element in a BST

Kth Smallest Element in a BST asks you to find the value with the requested rank among all values in a binary search tree, given its root and an integer k.

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