Untitled

mail@pastecode.io avatar
unknown
c_cpp
3 years ago
361 B
2
Indexable
Never
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;
}