How would null come in tree? what i should do in such case


  • 0
    A
     if(root->val<p->val&&root->val<q->val)
          lowestCommonAncestor(root->left,p,q);
         if(root->val>p->val&&root->val>q->val)
        lowestCommonAncestor(root->right,p,q);
        else
        return root;

Log in to reply
 

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