From 4856f9786b82c9ca54f2759679e1ef7c9e7a34b0 Mon Sep 17 00:00:00 2001 From: PeixiZ <96801981+PeixiZ@users.noreply.github.com> Date: Tue, 10 Jan 2023 15:49:23 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0C#=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=EF=BC=8C=E4=BD=BF=E7=94=A8=E4=B8=89=E6=8C=87=E9=92=88=E6=84=9F?= =?UTF-8?q?=E8=A7=89=E4=BC=9A=E6=9B=B4=E5=BD=A2=E8=B1=A1=E8=A1=A8=E8=BF=B0?= =?UTF-8?q?=E9=93=BE=E8=A1=A8=E7=BF=BB=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0206.翻转链表.md | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/problems/0206.翻转链表.md b/problems/0206.翻转链表.md index 44146bb4..7db80fe1 100644 --- a/problems/0206.翻转链表.md +++ b/problems/0206.翻转链表.md @@ -628,6 +628,43 @@ impl Solution { } } ``` +C#: +三指针法, 感觉会更直观: + +```cs +public LinkNumbers Reverse() +{ + ///用三指针,写的过程中能够弥补二指针在翻转过程中的想象 + LinkNumbers pre = null; + var move = root; + var next = root; + + while (next != null) + { + next = next.linknext; + move.linknext = pre; + pre = move; + move = next; + } + root = pre; + return root; +} + +///LinkNumbers的定义 +public class LinkNumbers +{ + /// + /// 链表值 + /// + public int value { get; set; } + + /// + /// 链表指针 + /// + public LinkNumbers linknext { get; set; } +} +``` +

From 241f3af9a8c74a5a42f53e9f39689fd1ab501655 Mon Sep 17 00:00:00 2001 From: shangcode <61669790+shangcode@users.noreply.github.com> Date: Wed, 11 Jan 2023 09:25:03 +0800 Subject: [PATCH 2/4] =?UTF-8?q?Update=200034.=E5=9C=A8=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E6=95=B0=E7=BB=84=E4=B8=AD=E6=9F=A5=E6=89=BE=E5=85=83=E7=B4=A0?= =?UTF-8?q?=E7=9A=84=E7=AC=AC=E4=B8=80=E4=B8=AA=E5=92=8C=E6=9C=80=E5=90=8E?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E4=BD=8D=E7=BD=AE.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 去掉了一个 Python 解法中的分号。 --- ...数组中查找元素的第一个和最后一个位置.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/problems/0034.在排序数组中查找元素的第一个和最后一个位置.md b/problems/0034.在排序数组中查找元素的第一个和最后一个位置.md index c7ff6dce..7e58a870 100644 --- a/problems/0034.在排序数组中查找元素的第一个和最后一个位置.md +++ b/problems/0034.在排序数组中查找元素的第一个和最后一个位置.md @@ -355,8 +355,8 @@ class Solution: while left <= right: middle = left + (right-left) // 2 if nums[middle] >= target: # 寻找左边界,nums[middle] == target的时候更新right - right = middle - 1; - leftBoder = right; + right = middle - 1 + leftBoder = right else: left = middle + 1 return leftBoder From 7d822fe65a587f883a5d63c1b72c139239f2cff7 Mon Sep 17 00:00:00 2001 From: El nino <69737612+el-nino2020@users.noreply.github.com> Date: Sat, 14 Jan 2023 09:18:08 +0800 Subject: [PATCH 3/4] =?UTF-8?q?Update=2020201003=E4=BA=8C=E5=8F=89?= =?UTF-8?q?=E6=A0=91=E5=91=A8=E6=9C=AB=E6=80=BB=E7=BB=93.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit typo? --- problems/周总结/20201003二叉树周末总结.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/problems/周总结/20201003二叉树周末总结.md b/problems/周总结/20201003二叉树周末总结.md index 18bbf37f..5f59b040 100644 --- a/problems/周总结/20201003二叉树周末总结.md +++ b/problems/周总结/20201003二叉树周末总结.md @@ -2,7 +2,7 @@ 本周赶上了十一国庆,估计大家已经对本周末没什么概念了,但是我们该做总结还是要做总结的。 -本周的主题其实是**简单但并不简单**,本周所选的题目大多是看一下就会的题目,但是大家看完本周的文章估计也发现了,二叉树的简答题目其实里面都藏了很多细节。 这些细节我都给大家展现了出来。 +本周的主题其实是**简单但并不简单**,本周所选的题目大多是看一下就会的题目,但是大家看完本周的文章估计也发现了,二叉树的简单题目其实里面都藏了很多细节。 这些细节我都给大家展现了出来。 ## 周一 From c201b947a5bb4510b5c0214ec652c6300a2c6760 Mon Sep 17 00:00:00 2001 From: El nino <69737612+el-nino2020@users.noreply.github.com> Date: Sat, 14 Jan 2023 15:06:56 +0800 Subject: [PATCH 4/4] =?UTF-8?q?Update=200112.=E8=B7=AF=E5=BE=84=E6=80=BB?= =?UTF-8?q?=E5=92=8C.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原有的代码leetcode上无法通过编译 --- problems/0112.路径总和.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/problems/0112.路径总和.md b/problems/0112.路径总和.md index 7aa5f2a1..b1f01336 100644 --- a/problems/0112.路径总和.md +++ b/problems/0112.路径总和.md @@ -155,14 +155,14 @@ public: 以上代码精简之后如下: ```cpp -class solution { +class Solution { public: bool hasPathSum(TreeNode* root, int sum) { - if (root == null) return false; + if (!root) return false; if (!root->left && !root->right && sum == root->val) { return true; } - return haspathsum(root->left, sum - root->val) || haspathsum(root->right, sum - root->val); + return hasPathSum(root->left, sum - root->val) || hasPathSum(root->right, sum - root->val); } }; ```