Is my accepted solution right?


  • 1
    H
    class Solution {
    public:
        bool isSubtree(TreeNode* s, TreeNode* t) {
            if(!s && !t) return true;
            if(s && t){
                if (s->val == t->val)if( isSubtree(s->left,t->left ) && isSubtree(t->right, s->right)) return true;
                if(isSubtree(s->left, t)) return true;
                if(isSubtree(s->right, t)) return true;
            }
            return false;
        }
    
    };
    

Log in to reply
 

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