Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 531 Bytes

File metadata and controls

18 lines (13 loc) · 531 Bytes
int sumOfLeafNodes(Node *root ){
              if(root->left==NULL && root->right==NULL)
                return root->data;
               
            int l=0,r=0;
            
            if(root->left)
                l=sumOfLeafNodes(root->left);
            
            if(root->right)
                r=sumOfLeafNodes(root->right);
                
            return l+r;
        }