From 71dd3eab9e9a005eec5669bfc25ba3cd4d27fb2f Mon Sep 17 00:00:00 2001 From: Luo <82520819+Jerry-306@users.noreply.github.com> Date: Fri, 11 Feb 2022 11:26:14 +0800 Subject: [PATCH 1/3] =?UTF-8?q?0059=20=20=E8=9E=BA=E6=97=8B=E7=9F=A9?= =?UTF-8?q?=E9=98=B5II=20=20=E9=A2=98=E7=9B=AE=E9=94=99=E8=AF=AF=E7=BA=A0?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0059.螺旋矩阵II.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/problems/0059.螺旋矩阵II.md b/problems/0059.螺旋矩阵II.md index 3f7a59ca..ff654358 100644 --- a/problems/0059.螺旋矩阵II.md +++ b/problems/0059.螺旋矩阵II.md @@ -10,7 +10,7 @@ [力扣题目链接](https://leetcode-cn.com/problems/spiral-matrix-ii/) -给定一个正整数 n,生成一个包含 1 到 $n^2$ 所有元素,且元素按顺时针顺序螺旋排列的正方形矩阵。 +给定一个正整数 n,生成一个包含 1 到 n^2 所有元素,且元素按顺时针顺序螺旋排列的正方形矩阵。 示例: From 3652d00e542fc251d479a66eb676c8e1ac910f45 Mon Sep 17 00:00:00 2001 From: Luo <82520819+Jerry-306@users.noreply.github.com> Date: Thu, 24 Feb 2022 17:49:15 +0800 Subject: [PATCH 2/3] =?UTF-8?q?0104=20=E4=BA=8C=E5=8F=89=E6=A0=91=E6=9C=80?= =?UTF-8?q?=E5=A4=A7=E6=B7=B1=E5=BA=A6=20=E9=83=A8=E5=88=86=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=B9=A6=E5=86=99=E9=94=99=E8=AF=AF=E7=BA=A0=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 函数错误,逻辑错误 --- problems/0104.二叉树的最大深度.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/problems/0104.二叉树的最大深度.md b/problems/0104.二叉树的最大深度.md index 3eecdc92..2229a854 100644 --- a/problems/0104.二叉树的最大深度.md +++ b/problems/0104.二叉树的最大深度.md @@ -523,8 +523,8 @@ func maxdepth(root *treenode) int { ```javascript var maxdepth = function(root) { - if (!root) return root - return 1 + math.max(maxdepth(root.left), maxdepth(root.right)) + if (root === null) return 0; + return 1 + Math.max(maxdepth(root.left), maxdepth(root.right)) }; ``` @@ -541,7 +541,7 @@ var maxdepth = function(root) { //3. 确定单层逻辑 let leftdepth=getdepth(node.left); let rightdepth=getdepth(node.right); - let depth=1+math.max(leftdepth,rightdepth); + let depth=1+Math.max(leftdepth,rightdepth); return depth; } return getdepth(root); @@ -591,7 +591,9 @@ var maxDepth = function(root) { count++ while(size--) { let node = queue.shift() - node && (queue = [...queue, ...node.children]) + for (let item of node.children) { + item && queue.push(item); + } } } return count From 14f91a53702d8df5e1a587e757f739b5df55bb8f Mon Sep 17 00:00:00 2001 From: Luo <82520819+Jerry-306@users.noreply.github.com> Date: Fri, 25 Feb 2022 10:37:17 +0800 Subject: [PATCH 3/3] =?UTF-8?q?0404=20=E5=B7=A6=E5=8F=B6=E5=AD=90=E4=B9=8B?= =?UTF-8?q?=E5=92=8C=20=20=E5=B7=A6=E5=8F=B6=E5=AD=90=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0404.左叶子之和.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/problems/0404.左叶子之和.md b/problems/0404.左叶子之和.md index 09272052..691c0f37 100644 --- a/problems/0404.左叶子之和.md +++ b/problems/0404.左叶子之和.md @@ -19,7 +19,7 @@ **首先要注意是判断左叶子,不是二叉树左侧节点,所以不要上来想着层序遍历。** -因为题目中其实没有说清楚左叶子究竟是什么节点,那么我来给出左叶子的明确定义:**如果左节点不为空,且左节点没有左右孩子,那么这个节点就是左叶子** +因为题目中其实没有说清楚左叶子究竟是什么节点,那么我来给出左叶子的明确定义:**如果左节点不为空,且左节点没有左右孩子,那么这个节点的左节点就是左叶子** 大家思考一下如下图中二叉树,左叶子之和究竟是多少?