From 5e08d1b8108b9c99cf1c2e8bb1ae12b5f6bcf822 Mon Sep 17 00:00:00 2001 From: ZerenZhang2022 <118794589+ZerenZhang2022@users.noreply.github.com> Date: Sun, 5 Mar 2023 16:21:15 -0500 Subject: [PATCH 1/5] =?UTF-8?q?Update=200019.=E5=88=A0=E9=99=A4=E9=93=BE?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=E5=80=92=E6=95=B0=E7=AC=ACN=E4=B8=AA?= =?UTF-8?q?=E8=8A=82=E7=82=B9.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改python版本为:fast先走n+1步 (旧版本是fast走n步,然后判断fast.next!=None),这样与上面的讲解一致 --- problems/0019.删除链表的倒数第N个节点.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/problems/0019.删除链表的倒数第N个节点.md b/problems/0019.删除链表的倒数第N个节点.md index b0641b5f..4e4474ca 100644 --- a/problems/0019.删除链表的倒数第N个节点.md +++ b/problems/0019.删除链表的倒数第N个节点.md @@ -129,10 +129,10 @@ class Solution: head_dummy.next = head slow, fast = head_dummy, head_dummy - while(n!=0): #fast先往前走n步 + while(n>=0): #fast先往前走n+1步 fast = fast.next n -= 1 - while(fast.next!=None): + while(fast!=None): slow = slow.next fast = fast.next #fast 走到结尾后,slow的下一个节点为倒数第N个节点 From 98a8a8b8b1c8068d1cc291b0770369318d867338 Mon Sep 17 00:00:00 2001 From: Du Zongwei <894588765@qq.com> Date: Mon, 6 Mar 2023 09:48:49 +0800 Subject: [PATCH 2/5] =?UTF-8?q?modified=20ACM=E4=B8=8B=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E4=BA=8C=E5=8F=89=E6=A0=91=20Python?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/前序/ACM模式如何构建二叉树.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/problems/前序/ACM模式如何构建二叉树.md b/problems/前序/ACM模式如何构建二叉树.md index 42bf7af0..b6446403 100644 --- a/problems/前序/ACM模式如何构建二叉树.md +++ b/problems/前序/ACM模式如何构建二叉树.md @@ -305,11 +305,12 @@ def construct_binary_tree(nums: []) -> TreeNode: Tree.append(node) if i == 0: root = node + # 直接判断2*i+2 Date: Mon, 6 Mar 2023 10:52:35 +0800 Subject: [PATCH 3/5] =?UTF-8?q?Update=200455.=E5=88=86=E5=8F=91=E9=A5=BC?= =?UTF-8?q?=E5=B9=B2.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0455.分发饼干.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/problems/0455.分发饼干.md b/problems/0455.分发饼干.md index 2437582c..63525b03 100644 --- a/problems/0455.分发饼干.md +++ b/problems/0455.分发饼干.md @@ -219,19 +219,17 @@ func findContentChildren(g []int, s []int) int { ### Rust ```rust -pub fn find_content_children(children: Vec, cookie: Vec) -> i32 { - let mut children = children; - let mut cookies = cookie; +pub fn find_content_children(mut children: Vec, mut cookie: Vec) -> i32 { children.sort(); cookies.sort(); - let (mut child, mut cookie) = (0usize, 0usize); + let (mut child, mut cookie) = (0, 0); while child < children.len() && cookie < cookies.len() { // 优先选择最小饼干喂饱孩子 if children[child] <= cookies[cookie] { child += 1; } - cookie += 1 + cookie += 1; } child as i32 } From 77eeed96bcfb0375e09d1a8f2d4e7a6afe9cd615 Mon Sep 17 00:00:00 2001 From: Yuhao Ju Date: Thu, 9 Mar 2023 00:13:05 +0800 Subject: [PATCH 4/5] =?UTF-8?q?update=200704.=E4=BA=8C=E5=88=86=E6=9F=A5?= =?UTF-8?q?=E6=89=BE:=20=E6=B7=BB=E5=8A=A0=E5=A4=8D=E6=9D=82=E5=BA=A6?= =?UTF-8?q?=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0704.二分查找.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/problems/0704.二分查找.md b/problems/0704.二分查找.md index a02bf7a2..2d5525ba 100644 --- a/problems/0704.二分查找.md +++ b/problems/0704.二分查找.md @@ -86,6 +86,9 @@ public: }; ``` +* 时间复杂度:O(log n) +* 空间复杂度:O(1) + ### 二分法第二种写法 @@ -124,6 +127,9 @@ public: } }; ``` +* 时间复杂度:O(log n) +* 空间复杂度:O(1) + ## 总结 From 337bf59ee6f703345d8e3371ec7e6ea6b8a013a5 Mon Sep 17 00:00:00 2001 From: Yuhao Ju Date: Thu, 9 Mar 2023 00:20:33 +0800 Subject: [PATCH 5/5] =?UTF-8?q?update=200059.=E8=9E=BA=E6=97=8B=E7=9F=A9?= =?UTF-8?q?=E9=98=B5II=EF=BC=9A=E6=B7=BB=E5=8A=A0=E5=A4=8D=E6=9D=82?= =?UTF-8?q?=E5=BA=A6=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0059.螺旋矩阵II.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/problems/0059.螺旋矩阵II.md b/problems/0059.螺旋矩阵II.md index d9a656b9..b4dad9c3 100644 --- a/problems/0059.螺旋矩阵II.md +++ b/problems/0059.螺旋矩阵II.md @@ -117,6 +117,9 @@ public: }; ``` +* 时间复杂度 O(n^2): 模拟遍历二维矩阵的时间 +* 空间复杂度 O(1) + ## 类似题目 * 54.螺旋矩阵