Preview:
int countLeaves(Node* root)
{
    int c=0;
    queue<Node*> q;
    q.push(root);
    
    while(!q.empty())
    {
        Node* temp=q.front();
        q.pop();
        
        if(temp->left==NULL&&temp->right==NULL) c++;
        
        if(temp->left) q.push(temp->left);
        if(temp->right) q.push(temp->right);
    }
    return c;
  // Your code here
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter