1 /** 2 * @param {number[]} nums 3 * @param {number} target 4 * @return {number[]} 5 */ 6 var twoSum = function (nums, target) { 7 const ll = nums.length 8 const numsMap = new Map() 9 for (let i = 0; ll - 1; i++) { 10 const complement = target - nums[i] 11 if (numsMap.get(complement) || numsMap.get(complement) === 0) { 12 return [i, numsMap.get(complement)] 13 } 14 numsMap.set(nums[i], i) 15 16 } 17 };
标签:const,nums,complement,get,number,numsMap,两数 From: https://www.cnblogs.com/yadayou/p/17846743.html