/* public class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val) { this.val = val; } } */ public class Solution { boolean isSymmetrical(TreeNode root) { if (root == null) { return true; } return isSymmetrical(root, root); } private boolean isSymmetrical(TreeNode left, TreeNode right) { if (left == null && right == null) { return true; } if (left == null || right == null) { return false; } return left.val == right.val && isSymmetrical(left.right, right.left) && isSymmetrical(left.left, right.right); } }