Simple Solution in CPP using resursion


#1

int Solution::isSameTree(TreeNode* A, TreeNode* B)
{
if(!A && !B)
return 1;
else if((!A && B) ||(!B && A))
return 0;
else if(A->val !=B->val)
return 0;
else
return isSameTree(A->left , B->left) && isSameTree(A->right ,B->right);

}