/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
int ans;
int n = 0;
int kthLargest(TreeNode* root, int k) {
myKthLargest(root, k);
return ans;
}
void myKthLargest(TreeNode *T, int k){
if (T == NULL){
return;
}
myKthLargest(T->right, k);
n++;
if(n == k){
ans = T->val;
return;
}
myKthLargest(T->left, k);
}
};