Given a Binary Search Tree and an integer k, implement a method to find and return its k^{th} largest node

**Example:**

In the above scenario, if k = 1, then the output is 10 i.e. k = 1, represents the largest element of the tree, k = 2, represents the second largest element and so on.

4

/ \

2 8

/ \

5 10

K = 2, Output = 8

In the above scenario, if k = 1, then the output is 10 i.e. k = 1, represents the largest element of the tree, k = 2, represents the second largest element and so on.

Need a **hand?** Try out these hints, one at a time.

The key here is to find the size of the right subtree at each node. If the

`size + 1`

is equal to `k`

, return that `node`

.
1. If root is

2. If root is

3. if this

4. If

5. Else, recurse through the left subtree with left node and k-rightSize-1. i.e.

`null`

then, return `null`

.2. If root is

`not null`

then find the the size of the right subtree of this node.3. if this

`size + 1`

is equal to k then `return`

this node.4. If

`k`

is less than right size then recurse with root.right i.e. `return findKthLargest(root.right, k)`

5. Else, recurse through the left subtree with left node and k-rightSize-1. i.e.

`return findKthLargest(root.left,`

`k-rightSize-1);`

public TreeNode findKthLargest(TreeNode root, int k) { }

**C**

**Java**

**Python**