← All problems

Kth Smallest Element in a BST

Medium treesbst LeetCode ↗
Given a binary search tree, find the kth smallest value among its nodes. Do better than a full sort; consider what an inorder traversal gives you and how to stop early.

Hints (0/3 revealed)

Log in to reveal hints progressively.

Complexity

Time O(h + k), Space O(h)

Common pitfalls

  • Full traversal when early stop suffices
  • Off-by-one on k (1-indexed)

Your solution

Log in to save your code and track progress.