Awesome, 2 LinesOfCode ( C++)


  • 0
    S
    bool isSameTree(TreeNode* p, TreeNode* q) {
            
    if (p==NULL && q==NULL) return true;
    if(p!=NULL&&q!=NULL) return (p->val==q->val&&isSameTree(p->right,q->right)&&isSameTree(p->left,q->left));
                
        
            return false;
        }

Log in to reply
 

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