Back to problems

Kth Smallest in a BST (LeetCode 230) with Follow-Ups

Algorithm · Salesforce · Hard

Given a binary search tree (BST) and a positive integer k, find and return the k-th smallest value among all nodes. The tree nodes are defined as follows: Implement an iterative solution that stops the traversal as soon as the target element is reached, without visiting the entire tree. Follow‑up 1: Frequent Tree Modifications The BST is now updated very often (insertions and deletions), and k-th smallest queries are also frequent. Augment each node to store the number of…

Checking your access…