Why this code can accept without a 'return true;' statement ?


  • 0
    V
    class Solution {
    public:
        bool isSameTree(TreeNode* p, TreeNode* q) {
            if( p && q)
            {
                if( p->val != q->val )
                    return false;
                return isSameTree( p->left, q->left ) && isSameTree( p->right, q->right );
            }
            else if( !p && !q )
            {
            }
            else
            {
                return false;
            }
        }
    };

Log in to reply
 

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