Created
October 22, 2019 14:01
-
-
Save daubattu/dde5c99dc947fb99e798798b24c50de2 to your computer and use it in GitHub Desktop.
[Hackerrank] Solution of Divisible Sum Pairs in JavaScript
This file contains 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
function divisibleSumPairs(n, k, ar) { | |
let result = 0; | |
for(let i = 0; i < n - 1; i++) { | |
result += ar.slice(i + 1, n).filter((item, index) => { | |
if ((item + ar[i]) % k === 0) { | |
return item; | |
} | |
}).length; | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
function divisibleSumPairs(n, k, ar) {
// Write your code here
var sum = 0;
var pair = 0;
}