Update 0001.两数之和.md
Add a break statement to break the for-loop in the Typescript solution.
This commit is contained in:
parent
db0bd95891
commit
a68d7c9937
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue