添加0104.二叉树的最大深度 JavaScript版代码
This commit is contained in:
parent
c78159d92a
commit
1168dc3095
|
|
@ -239,7 +239,13 @@ Python:
|
|||
Go:
|
||||
|
||||
|
||||
|
||||
JavaScript
|
||||
```javascript
|
||||
var maxDepth = function(root) {
|
||||
if (!root) return root
|
||||
return 1 + Math.max(maxDepth(root.left), maxDepth(root.right))
|
||||
};
|
||||
```
|
||||
|
||||
-----------------------
|
||||
* 作者微信:[程序员Carl](https://mp.weixin.qq.com/s/b66DFkOp8OOxdZC_xLZxfw)
|
||||
|
|
|
|||
Loading…
Reference in New Issue