Created
April 15, 2023 23:43
-
-
Save LuisitoRizado/5eced3d47d1ea87be4584c7fa3df9931 to your computer and use it in GitHub Desktop.
This is a solution for the 'Divisible sum pairs' by hackerrank
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 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