Skip to content

Commit 1b156d9

Browse files
authored
Create Sunny.md
1 parent df5316b commit 1b156d9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

2018.12.07-leetcode104/Sunny.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
```java
2+
class Solution {
3+
public int maxDepth(TreeNode root) {
4+
if (root == null) return 0;
5+
return Math.max(maxDepth(root.left, 1), maxDepth(root.right, 1));
6+
}
7+
8+
public int maxDepth(TreeNode node, int level) {
9+
if (node != null) {
10+
level = Math.max(maxDepth(node.left, level+1), maxDepth(node.right, level+1));
11+
}
12+
return level;
13+
}
14+
}
15+
```

0 commit comments

Comments
 (0)