leetcode-剑指54-OK

address

/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */


int kthLargest(struct TreeNode* root, int k){
    int count=0;
    void countALL(struct TreeNode* tree){
        if(tree ==NULL)
            return;
        countALL(tree->right);
        k--;
        if(k==0){
            count = tree->val;
            return;
        }
        countALL(tree->left);
    }
    countALL(root);
    return count;
}
posted @ 2021-01-25 01:23  RougeBW  阅读(33)  评论(0编辑  收藏  举报