您的位置:首页 > 其它

101. Symmetric Tree

2016-05-05 09:23 134 查看

Symmetric Tree

就是判断给定的一个树是不是中心对称树



代码

public class Solution {
public boolean isSymmetric(TreeNode root) {
return helper(root, root);
}

public boolean helper(TreeNode m, TreeNode n){
if(m == null && n == null){
return true;
}
if(m == null || n == null){
return false;
}

return m.val == n.val && helper(m.left, n.right) && helper(m.right, n.left);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: