题目:
代码:
/**
* Definition for a binary tree node.
* public class TreeNode {
* public int val;
* public TreeNode left;
* public TreeNode right;
* public TreeNode(int x) { val = x; }
* }
*/
public class Solution {
public bool IsSymmetric(TreeNode root) {
return Mirror (root,root) ;
}
public bool Mirror(TreeNode root1,TreeNode root2)
{
if(root1==null&&root2==null)
return true;
else if(root1==null||root2==null||root1.val!=root2.val)
return false;
else
{
return Mirror(root1.left,root2.right)&&Mirror(root1.right,root2.left);
}
}
}