Skip to content

Commit ca5a8d9

Browse files
committed
feat: maximum-depth-of-binary-tree solution
1 parent 5b11a4c commit ca5a8d9

File tree

1 file changed

+10
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)