Skip to content

Instantly share code, notes, and snippets.

@blessedjasonmwanza
Created March 8, 2022 07:35
Show Gist options
  • Save blessedjasonmwanza/0f010395d827f907fe2e6d9e4c0ce4fd to your computer and use it in GitHub Desktop.
Save blessedjasonmwanza/0f010395d827f907fe2e6d9e4c0ce4fd to your computer and use it in GitHub Desktop.
divisible sum pairs - HackerRank challenge solution
// addapted from https://www.hackerrank.com/challenges/divisible-sum-pairs/problem?isFullScreen=true
function divisibleSumPairs(n, k, ar) {
let counter = 0;
for(let i = 0; i< n; i++){
for(let j = 0; j< n; j++){
if(i < j && (ar[i] + ar[j]) % k === 0){
counter +=1;
}
}
}
return counter;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment