deno.land / x / masx200_leetcode_test@10.6.5 / two-sum / index.ts
123456789101112131415export default function two_Sum(nums: number[], target: number): number[] { const storeNumstoindex = new Map<number, number>();
for (const [i, num1] of nums.entries()) { const num2 = target - num1; const index2 = storeNumstoindex.get(num2); if (typeof index2 !== "undefined") { return [i, index2]; } else { storeNumstoindex.set(num1, i); } } throw Error("should not go here");}
Version Info