Created
January 16, 2022 18:56
-
-
Save see-why/0ad8d0ed7eeb9d9ef35a1b1b1979e596 to your computer and use it in GitHub Desktop.
HackerRank Divisible Sum Pairs challenge
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
//https://www.hackerrank.com/challenges/divisible-sum-pairs/problem?isFullScreen=true&h_r=next-challenge&h_v=zen | |
function divisibleSumPairs(n, k, ar) { | |
// Write your code here | |
let count = 0; | |
let sum = 0; | |
ar.map((item, index) => { | |
for (let i=index + 1; i < ar.length; i++){ | |
sum = item + ar[i] ; | |
if( sum % k == 0){ | |
count++; | |
} | |
} | |
}) | |
return count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment