0 ms C solution :)


  • 2
    S

    bool isSameTree(struct TreeNode* p, struct TreeNode* q) {

    if(p==NULL && q==NULL)
    return true;
    if(p==NULL || q==NULL)
    return false;

        return (p->val==q->val && isSameTree(p->left,q->left) && isSameTree(p->right, q->right));
    }

Log in to reply
 

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