Skip to content

Commit fceb9c3

Browse files
authored
Merge pull request gzc426#380 from beddingearly/master
2
2 parents ad34c27 + ca69d22 commit fceb9c3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 int maxDepth(TreeNode root) {
13+
int left;
14+
int right;
15+
if (root == null){
16+
return 0;
17+
}
18+
else {
19+
left = maxDepth(root.left) + 1;
20+
right = maxDepth(root.right) + 1;
21+
}
22+
return left > right ? left : right;
23+
}
24+
}
25+
```

0 commit comments

Comments
 (0)