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 84d172b commit 67cd52eCopy full SHA for 67cd52e
two-sum/krokerdile.js
@@ -0,0 +1,15 @@
1
+/**
2
+ * @param {number[]} nums
3
+ * @param {number} target
4
+ * @return {number[]}
5
+ */
6
+var twoSum = function(nums, target) {
7
+ let dict = new Map();
8
+
9
+ for(const [index, num] of nums.entries()){
10
+ if(dict.has(target-num) && dict.get(target-num) != index){
11
+ return [dict.get(target-num),index];
12
+ }
13
+ dict.set(num, index);
14
15
+};
0 commit comments