Skip to content

Commit e8d7ea4

Browse files
author
Alejandro Gonzalez Romero
committed
feat: divisible sum pairs algorithm
1 parent 61f5c0c commit e8d7ea4

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@
3434
| 10 | Warmup | [Birthday Cake Candles](https://www.hackerrank.com/challenges/birthday-cake-candles) | [Solution](https://github.com/algorodev/hackerrank-challenges/blob/master/algorithms/warmup/birthday-cake-candles/birthday-cake-candles.js) | Easy | 10 |
3535
| 11 | Implementation | [Grading Students](https://www.hackerrank.com/challenges/grading) | [Solution](https://github.com/algorodev/hackerrank-challenges/blob/master/algorithms/implementation/grading-students/grading-students.js) | Easy | 10 |
3636
| 12 | Implementation | [Apple and Orange](https://www.hackerrank.com/challenges/apple-and-orange) | [Solution](https://github.com/algorodev/hackerrank-challenges/blob/master/algorithms/implementation/apple-and-orange/count-apples-and-oranges.js) | Easy | 10 |
37-
| 13 | Implementation | [Between Two Sets](https://www.hackerrank.com/challenges/between-two-sets) | [Solution](https://github.com/algorodev/hackerrank-challenges/blob/master/algorithms/implementation/between-two-sets/get-total-x.js) | Easy | 10 |
38-
| 14 | Implementation | [Number Line Jumps](https://www.hackerrank.com/challenges/number-line-jumps) | [Solution](https://github.com/algorodev/hackerrank-challenges/blob/master/algorithms/implementation/number-line-jumps/kangaroo.js) | Easy | 10 |
37+
| 13 | Implementation | [Number Line Jumps](https://www.hackerrank.com/challenges/number-line-jumps) | [Solution](https://github.com/algorodev/hackerrank-challenges/blob/master/algorithms/implementation/number-line-jumps/kangaroo.js) | Easy | 10 |
38+
| 14 | Implementation | [Between Two Sets](https://www.hackerrank.com/challenges/between-two-sets) | [Solution](https://github.com/algorodev/hackerrank-challenges/blob/master/algorithms/implementation/between-two-sets/get-total-x.js) | Easy | 10 |
3939
| 15 | Implementation | [Subarray Division](https://www.hackerrank.com/challenges/the-birthday-bar) | [Solution](https://github.com/algorodev/hackerrank-challenges/blob/master/algorithms/implementation/subarray-division/birthday.js) | Easy | 10 |
40+
| 16 | Implementation | [Divisible Sum Pairs](https://www.hackerrank.com/challenges/divisible-sum-pairs) | [Solution](https://github.com/algorodev/hackerrank-challenges/blob/master/algorithms/implementation/divisible-sum-pairs/divisible-sum-pairs.js) | Easy | 10 |
4041

4142
## Data Structures
4243

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const divisibleSumPairs = (n, k, ar) => {
2+
let count = 0
3+
4+
for (let i = 0; i < ar.length; i++) {
5+
for (let j = 0; j < n; j++) {
6+
if (i < j && (ar[i] + ar[j]) % k === 0) {
7+
count++
8+
}
9+
}
10+
}
11+
12+
return count
13+
}

0 commit comments

Comments
 (0)