Created
March 8, 2022 07:35
-
-
Save blessedjasonmwanza/0f010395d827f907fe2e6d9e4c0ce4fd to your computer and use it in GitHub Desktop.
divisible sum pairs - HackerRank challenge solution
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
// 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