Skip to content

Latest commit

 

History

History
24 lines (16 loc) · 620 Bytes

File metadata and controls

24 lines (16 loc) · 620 Bytes
 int isSumProperty(Node *root)
    {
    
    if(root==NULL || (root->left==NULL && root->right==NULL))
            return 1;
            
        int l=0,r=0;
        
        if(root->left)
             l=root->left->data;
        
        if(root->right)
             r=root->right->data;
            
        if(root->data !=(l+r))
            return 0;
        
        return (isSumProperty(root->left)==1 && isSumProperty(root->right)==1) ? 1:0;
    }