We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ea7ab9a + 38f826b commit 9f4f187Copy full SHA for 9f4f187
2018.12.04-leetcode101/杨.md
@@ -0,0 +1,25 @@
1
+```
2
+ /**
3
+ * 如果一个树的左子树与右子树镜像对称,那么这个树是对称的。
4
+ * 如果同时满足下面的条件,两个树互为镜像:
5
+ * 1.它们的两个根结点具有相同的值。
6
+ * 2.每个树的右子树都与另一个树的左子树镜像对称。
7
+ */
8
+ public boolean isSymmetric(TreeNode root) {
9
+ if(root == null ){
10
+ return true;
11
+ }
12
+ return isMirrorSymmetry(root.left,root.right);
13
14
+
15
+ public boolean isMirrorSymmetry(TreeNode left,TreeNode right){
16
+ if(left==null && right==null){
17
18
19
+ if(left==null || right==null){
20
+ return false;
21
22
+ return left.val==right.val && isMirrorSymmetry(left.left,right.right) && isMirrorSymmetry(left.right,right.left);
23
24
25
0 commit comments