Skip to content

Instantly share code, notes, and snippets.

@see-why
Created January 16, 2022 18:56
Show Gist options
  • Save see-why/0ad8d0ed7eeb9d9ef35a1b1b1979e596 to your computer and use it in GitHub Desktop.
Save see-why/0ad8d0ed7eeb9d9ef35a1b1b1979e596 to your computer and use it in GitHub Desktop.
HackerRank Divisible Sum Pairs challenge
//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