Created
January 6, 2022 07:42
-
-
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 …
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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