Untitled
4 years ago in Plain Text
var TEST = function () {
return {
exec: function (arr, sum) {
const map = new Map();
for (let i=0; i<arr.length; ++i) {
const sub = sum - arr[i];
if (map.has(sub)) {
return [ map.get(sub), i ];
}
map.set(arr[i], i);
}
}
};
}();