"0 ms" C++ Solution

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

Log in to reply

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