Problem
Ask
Submissions

Problem: Kth Smallest Element in a BST

Medium
30 min
Explore how to solve the problem of finding the kth smallest element in a binary search tree. Understand the use of depth-first search and practice implementing an efficient solution that runs in linear time with optimal space usage.

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
  • 00 \leq Node.data 104\leq 10^4
Problem
Ask
Submissions

Problem: Kth Smallest Element in a BST

Medium
30 min
Explore how to solve the problem of finding the kth smallest element in a binary search tree. Understand the use of depth-first search and practice implementing an efficient solution that runs in linear time with optimal space usage.

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
  • 00 \leq Node.data 104\leq 10^4