Medium · Trees
Find Kth Largest in BST
Given the root of a binary search tree with distinct values and an integer k with 1 ≤ k ≤ the number of nodes, return the kth largest value in the tree.
Examples
Example 1
[5,3,8,2,4,7,9], k=2Output: 2nd largest = 8
Example 2
[4,2,6,1,3,5,7], k=3Output: 3rd largest = 5
Rebuild it in the studio
Core interview problems are free with a full runner and lessons; Pro opens the complete library.