Skip to content

Instantly share code, notes, and snippets.

@mmsesay
Created January 6, 2022 07:42
Show Gist options
  • Save mmsesay/52302c188654c8fd008cfd9dbad707ca to your computer and use it in GitHub Desktop.
Save mmsesay/52302c188654c8fd008cfd9dbad707ca to your computer and use it in GitHub Desktop.
Submissions Leaderboard Discussions Editorial There will be two arrays of integers. Determine all integers that satisfy the following two conditions: The elements of the first array are all factors of the integer being considered The integer being considered is a factor of all elements of the second array These numbers are referred to as being …
// https://www.hackerrank.com/challenges/between-two-sets/problem?isFullScreen=true
const getTotalX = (a, b) => {
const setAMax = Math.max(...a);
const setBMin = Math.min(...b);
let count = 0;
for(let i = setAMax; i <= setBMin; 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