Search
⌘K

Leetcode 230. Kth Smallest Element in a BST

Return the k-th smallest value (1-indexed) in a BST — exploit that an in-order traversal yields values in sorted order and pick the k-th visited node. For frequent updates/queries, augment the BST with subtree sizes (an order-statistic tree) to support O(log n) queries and updates.

Asked at:

Amazon

Amazon

Meta

Google

Google


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Early March, 2025

Meta

Senior

Early February, 2025

Google

Google

Junior

Mid January, 2025

Amazon

Amazon

Senior

Find the kth smallest element in a BST

Comments

Your account is free and you can post anonymously if you choose.