From 7d9ec4360849d8363d7df07d631f3787f10e21bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=92=E6=98=9F=E8=A7=82=E6=B5=8B=E5=91=983400=E5=8F=B7?= <1063934054@qq.com> Date: Thu, 13 May 2021 22:01:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A00104.=E4=BA=8C=E5=8F=89?= =?UTF-8?q?=E6=A0=91=E7=9A=84=E6=9C=80=E5=A4=A7=E6=B7=B1=E5=BA=A6=20JavaSc?= =?UTF-8?q?ript=E7=89=88=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0104.二叉树的最大深度.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/problems/0104.二叉树的最大深度.md b/problems/0104.二叉树的最大深度.md index 814beb55..b7eb8142 100644 --- a/problems/0104.二叉树的最大深度.md +++ b/problems/0104.二叉树的最大深度.md @@ -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)