LeetCode #101: Symmetric Tree | Amazon Coding Interview

preview_player
Показать описание
Amazon Coding interview question - Symmetric Tree (Leetcode)
**** Best Books For Data Structures & Algorithms for Interviews:

#Amazon #Facebook #CodingInterview #LeetCode #SymmetricTree #Google
Рекомендации по теме
Комментарии
Автор

sir what is wrong i have written the same code but in my language why is it giving wrong ans?

bool areMirror(TreeNode *root1, TreeNode *root2){
if(root1 == NULL && root2 == NULL){
return true;
}else if(root1 == NULL || root2 == NULL){
return false;
}else if(root1 -> val == root2 -> val){
return true;
}


return areMirror(root1 -> left, root2 -> right) && areMirror(root1 -> right, root2 -> left);


}

bool isSymmetric(TreeNode* root) {
if(root == NULL){
return true;
}

return areMirror(root -> left, root -> right);
}

atharvakulkarni
join shbcf.ru