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