题目
给你一个二叉树的根节点 root , 检查它是否轴对称。
示例 1:
输入:root = [1,2,2,3,4,4,3]
输出:true
解
class Solution {public boolean isSymmetric(TreeNode root) {return isSymm(root.left,root.right);}public boolean isSymm(TreeNode leftNode,TreeNode rightNode){if(leftNode == null && rightNode == null){return true;}else if(leftNode == null || rightNode == null){return false;}else if(leftNode.val != rightNode.val){return false;}return isSymm(leftNode.right,rightNode.left) && isSymm(leftNode.left,rightNode.right);}
}