Untitled

 avatar
unknown
c_cpp
4 years ago
361 B
7
Indexable
int max = INT_MIN;                              //Global variable

void findMax(int root){
    if(root==NULL)  return;

    if(!root->right && !root->left){
        if(root->val > max) 
            max = root->val;
        return;
    }

    if(root->val > max)
        max = root->val;

    findMax(root->left);
    findMax(root->right);
    
    return min;
}
Editor is loading...