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 038a0eb commit 59a5cfbCopy full SHA for 59a5cfb
1 file changed
two-sum/reeseo3o.js
@@ -0,0 +1,13 @@
1
+const twoSum = (nums, target) => {
2
+ const map = {};
3
+
4
+ for (let i = 0; i < nums.length; i++) {
5
+ const complement = target - nums[i];
6
7
+ if (complement in map) {
8
+ return [map[complement], i];
9
+ }
10
11
+ map[nums[i]] = i;
12
13
+};
0 commit comments