Skip to content

Commit 7a4d0f2

Browse files
authored
Merge pull request gzc426#16 from ADemoDemo/ADemoDemo-patch-10
Create Avalon.md
2 parents d1da20e + 423d484 commit 7a4d0f2

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

2018.12.04-leetcode101/Avalon.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Definition for a binary tree node.
3+
* public class TreeNode {
4+
* int val;
5+
* TreeNode left;
6+
* TreeNode right;
7+
* TreeNode(int x) { val = x; }
8+
* }
9+
*/
10+
class Solution {
11+
public boolean isSymmetric(TreeNode root) {
12+
if (root == null ){
13+
return true;
14+
}
15+
16+
return isSymmetric(root.left, root.right);
17+
}
18+
19+
public static boolean isSymmetric(TreeNode nodeA, TreeNode node_A){
20+
if (node_A == null && nodeA == null) {
21+
return true;
22+
}
23+
if (node_A != null && nodeA != null) {
24+
return node_A.val == nodeA.val && isSymmetric(nodeA.left, node_A.right) && isSymmetric(nodeA.right, node_A.left);
25+
}
26+
return false;
27+
}
28+
}

0 commit comments

Comments
 (0)