From a68d7c99370b6e2dd20c6485c1c408b8b0bf5327 Mon Sep 17 00:00:00 2001 From: Nicolas Leigh Date: Thu, 18 Apr 2024 13:21:39 +0800 Subject: [PATCH] =?UTF-8?q?Update=200001.=E4=B8=A4=E6=95=B0=E4=B9=8B?= =?UTF-8?q?=E5=92=8C.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a break statement to break the for-loop in the Typescript solution. --- problems/0001.两数之和.md | 1 + 1 file changed, 1 insertion(+) diff --git a/problems/0001.两数之和.md b/problems/0001.两数之和.md index 80218cb5..d40cade8 100644 --- a/problems/0001.两数之和.md +++ b/problems/0001.两数之和.md @@ -349,6 +349,7 @@ function twoSum(nums: number[], target: number): number[] { index = helperMap.get(target - nums[i]); if (index !== undefined) { resArr = [i, index]; + break; } helperMap.set(nums[i], i); }