class Solution {
public:
bool isSymmetric(TreeNode* root) {
if(!root)
return true;
return ismirrow(root,root);
}
bool ismirrow(TreeNode* T1,TreeNode* T2)
{
if(T1==NULL&&T2==NULL)
return true;
if(!T1||!T2)
return false;
if(T1->val==T2->val)
return ismirrow(T1->left,T2->right)&&ismirrow(T1->right,T2->left);
return false;
}
};
注意:
抓住两树镜像对称:
1.根结点相等
2.T1左儿子和T2右儿子相等