Skip to content

Commit 6127e05

Browse files
committed
[leet] maxDepth
1 parent 1b01a73 commit 6127e05

File tree

1 file changed

+8
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)