Update 0001.两数之和.md

Add a break statement to break the for-loop in the Typescript solution.
This commit is contained in:
Nicolas Leigh
2024-04-18 13:21:39 +08:00
committed by GitHub
parent db0bd95891
commit a68d7c9937

View File

@ -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);
}