Skip to content

Commit f13af8c

Browse files
authored
Create Saul.md
1 parent 18e17bc commit f13af8c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

2018.12.07-leetcode104/Saul.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 int maxDepth(TreeNode root) {
13+
if(root == null){
14+
return 0;
15+
}
16+
int leftLen = maxDepth(root.left);
17+
int rightLen = maxDepth(root.right);
18+
return Math.max(leftLen,rightLen)+1;
19+
20+
}
21+
}
22+
```

0 commit comments

Comments
 (0)