Skip to content

Commit f82635d

Browse files
committed
增加No965
1 parent 125e1de commit f82635d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

leetcode/Tree/No965.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package Algorithm.leetcode.Tree;
2+
3+
/**
4+
* No965
5+
*
6+
* Created by tujietg on Jan 21, 2020
7+
*/
8+
public class No965 {
9+
public boolean isUnivalTree(TreeNode root) {
10+
if (root == null) {
11+
return true;
12+
}
13+
if (root.left != null && root.left.val != root.val) {
14+
return false;
15+
}
16+
if (root.right != null && root.right.val != root.val) {
17+
return false;
18+
}
19+
20+
return isUnivalTree(root.left) && isUnivalTree(root.right);
21+
}
22+
}

0 commit comments

Comments
 (0)