bool isSymmetricalTree(struct TreeNode* pRoot, struct TreeNode* pRoot2) {
if (pRoot == NULL && pRoot2 == NULL)
return true;
if (pRoot == NULL || pRoot2 == NULL)
return false;
if (pRoot->val == pRoot2->val) {
if (isSymmetricalTree(pRoot->left, pRoot2->right) &&
isSymmetricalTree(pRoot2->left, pRoot->right))
return true;
}
return false;
}
bool isSymmetrical(struct TreeNode* pRoot ) {
// write code here
if (pRoot == NULL)
return true;
return isSymmetricalTree(pRoot->left, pRoot->right);
}



京公网安备 11010502036488号