Skip to content

Commit fd56326

Browse files
committed
maximum-depth-of-binary-tree
1 parent db34023 commit fd56326

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function maxDepth(root: TreeNode | null): number {
2+
if (!root) return 0;
3+
const left = maxDepth(root.left);
4+
const right = maxDepth(root.right);
5+
return Math.max(left, right) + 1;
6+
}

0 commit comments

Comments
 (0)