You are given the root of a Binary Search Tree (BST) and an integer k. Your task is to find the kth largest value among all node values in the tree.
Return the kth largest element present in the BST.
Input: root = [5,3,8,1,4,null,9], k = 2
Output: 8
Explanation: In descending order the values are 9, 8, 5, 4, 3, 1. The 2nd largest value is 8.
Input: root = [5,3,8,1,4,null,9], k = 1
Output: 9
Explanation: The largest value in the BST is 9.
Input: root = [42], k = 1
Output: 42
Explanation: The only value is both the largest and the 1st largest element.
Sign in to write, run, and submit your solution against the full test suite.