Meesho BST Kth Smallest Element
Meesho BST Kth Smallest Element
MediumTrees100% accepted
Meesho maintains product prices in a BST for quick range queries. Given the root of a BST and an integer k, return the kth smallest value (1-indexed) among all nodes. A BST in-order traversal yields sorted order.
Approach
Find the kth smallest element in a BST using in-order traversal.
Input
5
3 1 4 -1 2
1
Output
1
More Trees problems
Browse all coding problems →solution.py
Loading editor...
Test 1
Test 2
Test 3
Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards