My AC Crecursive algrithms


  • 0
    W

    bool isSameTree(struct TreeNode *p, struct TreeNode *q) {
    int flag=true;
    if(p&&q)
    {
    if(p->val!=q->val)
    flag=false;
    flag=flag&&isSameTree(p->left,q->left)&&isSameTree(p->right,q->right);
    }else{
    if((p&&!q)||(!p&&q))
    flag=false;
    };
    return flag;
    }


Log in to reply
 

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