Skip to content

Commit 9cbb1eb

Browse files
committed
maximum depth of binary tree solved
1 parent 5c009e6 commit 9cbb1eb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution {
2+
public int maxDepth(TreeNode root) {
3+
if(root == null){
4+
return 0;
5+
}
6+
7+
return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1;
8+
}
9+
}

0 commit comments

Comments
 (0)