We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 22f71ca commit b9cb9d9Copy full SHA for b9cb9d9
two-sum/soobing2.ts
@@ -0,0 +1,15 @@
1
+function twoSum(nums: number[], target: number): number[] {
2
+ const map = new Map();
3
+ for (let i = 0; i < nums.length; i++) {
4
+ map.set(nums[i], i);
5
+ }
6
+
7
8
+ const index = map.get(target - nums[i]);
9
+ if (i === index || index === undefined) continue;
10
11
+ return [i, index];
12
13
14
+ return [];
15
+}
0 commit comments