Nums given an integer array and the target value of an integer target, can you please find out and in the array for the target values of the two integers, and returns the array subscript,
You can assume that each input only corresponding to an answer,
However, in the answer can't repeat the same element in an array,
You can return the answer in any order,
Please use js code
You first think, one day, can't think out, give you the answer tomorrow,
CodePudding user response:
Var nums=,6,5,7,4,2 [9];
Var target=10;
Var k={};
for (var i=0; I & lt; Nums. Length; I++) {
If (nums [I] in k) {
The console. The log (k/nums [I]], I);
break;
}
K [target - nums [I]]=I;
}