Skip to content

Instantly share code, notes, and snippets.

@LuisitoRizado
Created April 15, 2023 23:43
Show Gist options
  • Save LuisitoRizado/5eced3d47d1ea87be4584c7fa3df9931 to your computer and use it in GitHub Desktop.
Save LuisitoRizado/5eced3d47d1ea87be4584c7fa3df9931 to your computer and use it in GitHub Desktop.
This is a solution for the 'Divisible sum pairs' by hackerrank
function divisibleSumPairs(n, k, ar) {
let sum = 0;
let pairs = 0;
//two loops
for(let i = 0; i<ar.length; i++){
//second loop
for(let j = i+1; j<ar.length; j++){
if((ar[i]+ar[j])%k==0){
pairs++;
}
}
}
return pairs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment