From 1965ff69f70373fd48f31c590e77152444ceefe3 Mon Sep 17 00:00:00 2001 From: chenwingsing <742474834@qq.com> Date: Sun, 3 Jul 2022 09:07:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0[0015.=E4=B8=89=E6=95=B0?= =?UTF-8?q?=E4=B9=8B=E5=92=8C]=E8=A7=A3=E9=A2=98=E6=8F=8F=E8=BF=B0?= =?UTF-8?q?=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加逗号让解题更加清晰,避免歧义,我一开始就看成a = num[i] *b了 --- problems/0015.三数之和.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/problems/0015.三数之和.md b/problems/0015.三数之和.md index 4f1d711a..8bc8dd91 100644 --- a/problems/0015.三数之和.md +++ b/problems/0015.三数之和.md @@ -95,7 +95,7 @@ public: 拿这个nums数组来举例,首先将数组排序,然后有一层for循环,i从下标0的地方开始,同时定一个下标left 定义在i+1的位置上,定义下标right 在数组结尾的位置上。 -依然还是在数组中找到 abc 使得a + b +c =0,我们这里相当于 a = nums[i] b = nums[left] c = nums[right]。 +依然还是在数组中找到 abc 使得a + b +c =0,我们这里相当于 a = nums[i],b = nums[left],c = nums[right]。 接下来如何移动left 和right呢, 如果nums[i] + nums[left] + nums[right] > 0 就说明 此时三数之和大了,因为数组是排序后了,所以right下标就应该向左移动,这样才能让三数之和小一些。