/**
* 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) {
if(root==null)
return true;
return IsMirror(root.left,root.right);
}
private bool IsMirror(TreeNode l,TreeNode r)
{
if(l==null&&r==null)
return true;
if((l==null&&r!=null)||(l!=null&&r==null)||l.val!=r.val)
return false;
return IsMirror(l.left,r.right)&&IsMirror(l.right,r.left);
}
}
题目C#代码/** * 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 IsSy