第K大,所以右根左;第K小才是左根右
class Solution {
int count = 0, result = 0;
public int kthLargest(TreeNode root, int k) {
dfs(root, k);
return result;
}
public void dfs(TreeNode root, int k){
if(root.right != null) dfs(root.right, k);
if(++count == k){
result = root.val;
return;
}
if(root.left != null) dfs(root.left, k);
}
}