题解 | #对称的二叉树#
对称的二叉树
http://www.nowcoder.com/practice/ff05d44dfdb04e1d83bdbdab320efbcb
/*
public class TreeNode {
int val = 0;
TreeNode left = null;
TreeNode right = null;
public TreeNode(int val) {
this.val = val;
}
}
*/
public class Solution {
boolean isSame(TreeNode L,TreeNode R){
if(L==null && R==null) return true;
if(L==null || R==null) return false;
return L.val==R.val && isSame(L.left,R.right) && isSame(L.right,R.left);
}
boolean isSymmetrical(TreeNode pRoot) {
return isSame(pRoot,pRoot);
}
}
递归