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 0a0ef4c commit a07a75dCopy full SHA for a07a75d
LeetCode/1. Two Sum/index.js
@@ -0,0 +1,10 @@
1
+var twoSum = function(nums, target) {
2
+ let hashSet = new Set();
3
+ for (let i = 0; i < nums.length; i++) {
4
+ if (hashSet.has(target - nums[i])) {
5
+ return [i, nums.indexOf(target - nums[i])];
6
+ } else {
7
+ hashSet.add(nums[i]);
8
+ }
9
10
+};
0 commit comments