Skip to content

Instantly share code, notes, and snippets.

@see-why
Created December 23, 2021 07:54
Show Gist options
  • Save see-why/eab41731d6f54bd8a2782683f587789d to your computer and use it in GitHub Desktop.
Save see-why/eab41731d6f54bd8a2782683f587789d to your computer and use it in GitHub Desktop.
Between two sets HackerRank Challenge
function getTotalX(a, b) {
// Write your code here
let start = Math.max(...a);
let end = Math.min(...b);
let count = 0;
for(let i = start; i <= end; i++){
let arr_factors = a.filter((e) => i % e == 0);
let arr_multiples = b.filter((e) => e % i == 0);
if (arr_factors.length == a.length && arr_multiples.length == b.length) {
count++;
}
}
return count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment