Count Leaves in Binary Tree

PHOTO EMBED

Sat Dec 02 2023 18:26:25 GMT+0000 (Coordinated Universal Time)

Saved by @nistha_jnn #c++

int countLeaves(Node* root)
{
   if(!root)
   return 0;
   if(root->left==NULL and root->right==NULL)
   {
       return 1;
   }
   return (countLeaves(root->left)+countLeaves(root->right));
}
content_copyCOPY