Skip to content

Commit 547d29b

Browse files
authored
Merge pull request gzc426#274 from coolbhy/patch-3
Create 啦啦啦.md
2 parents 2a95f14 + 3a2fd44 commit 547d29b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

2018.12.4-leetcode101/啦啦啦.md

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

0 commit comments

Comments
 (0)