-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem1.js
More file actions
34 lines (28 loc) · 692 Bytes
/
Copy pathproblem1.js
File metadata and controls
34 lines (28 loc) · 692 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function betterAnswer (numbers, k) {
const remainders = new Set();
for (number of numbers) {
if (number <= k) {
if (remainders.has(number)) {
return true;
} else {
remainders.push(k - number);
}
}
}
return false;
}
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
function makeList() {
const nums = []
for (i = 0; i < 100000; i++) {
nums.push(getRandomArbitrary(1, 100));
}
return nums;
}
const start = new Date();
const liste = makeList();
betterAnswer(liste, 0);
const stop = new Date() - start;
console.log(stop/1000);