Dsa
Binary Search Tree
Hard
Kth Largest Element in BST
Given a binary search tree, find the k-th largest element in it. Note that the largest element is the one with the highest value. Use the property of the BST to achieve this efficiently.
Input format:
The first line contains an integer N, the number of nodes in the BST. The second line contains an integer k.
The next N lines each contain an integer value for each node in level order.
Output format:
Print the k-th largest element.
Example:
Input:
5
2
10
5
15
3
7
Output:
10
Key concepts
binary_search_treekth_largestinorder_traversal
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now