public bool IsSymmetric(TreeNode root) { bool ok; if (root == null) { return true; } ok = Rec(root.left, root.right); return ok; }
public static bool Rec(TreeNode one, TreeNode two) { if (one == null && two == null) { return true; } else if (one == null || two == null) { return false; } else if (one.val != two.val) { return false; } bool ok = Rec(one.left, two.right) && Rec(one.right, two.left); return ok; }