Skip to content
Veltoryx Technologies
ProProblem 102● MediumLeetCode #230 ↗3 min readUpdated 30 October 2026

Kth Smallest Element in a BST

Find the kth smallest value in a BST using an iterative stack with early termination.

01The problem

Given the root of a binary search tree, and an integer k, return the k-th smallest value (1-indexed) of all the values of the nodes in the tree.

text
       5
      /      3   6
    /    2   4
  /
 1

k = 3
Inorder: [1, 2, 3, 4, 5, 6]
3rd smallest: 3
Output: 3

Constraints

  • The number of nodes in the tree is n.
  • 1 <= k <= n <= 10^4
  • 0 <= Node.val <= 10^4

Loading the rest of the lesson…