OTL is coming to my solution .please comment


  • 0
    V
    if(root==NULL)
                                return 0;
                        else if ((root->left==NULL) && (root->right==NULL))
                                return 1;
                        else
                        {
                                int left=minDepth(root->left);
                                int right=minDepth(root->right);
                                cout<<"  left "<<left<<" right"<<" "<<right<<" "<<root->val<<endl;
                                if(left&&right){
                                        if(left<=right){
                                                return left+1;
                                        }
                                        else
    
                                                return right +1;}
                                else{
                                        if(!left)
                                                return right+1;
                                        else
                                                return left+1;
    
                                }
    
    
                        }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.