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
// Definition of types | |
type Pick<T, K extends keyof T> = { | |
[P in K]: T[P]; | |
} | |
type Record<K extends string, T> = { | |
[P in K]: T; | |
} |
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
/* | |
Solution for HackerRank > Algorithms > Warmup > Diagonal Difference | |
https://www.hackerrank.com/challenges/simple-array-sum/diagonal-difference | |
See explanation in Russian at https://www.coursera.org/learn/algoritmizacija-vychislenij/lecture/zinYi/opriedielieniie-indieksov-eliemientov-matritsy-raspolozhiennykh-na-nad-i-pod | |
*/ | |
(function solve(n, matrix) { | |
const diagonals = [0, 0]; | |
for (let i = 1; i < n + 1; i += 1) { |
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
/* | |
Solution for HackerRank > Algorithms > Warmup > Simple Array Sum | |
https://www.hackerrank.com/challenges/simple-array-sum/ | |
*/ | |
(function solve(n, ar) { | |
return ar.reduce((a, b) => a + b); | |
})(6, [1, 2, 3, 4, 10, 11]); |
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
/* | |
Solution for HackerRank > Algorithms > Warmup > Compare the Triplets | |
https://www.hackerrank.com/challenges/compare-the-triplets | |
*/ | |
(function solve(a0, a1, a2, b0, b1, b2) { | |
var aa = [a0, a1, a2]; | |
var bb = [b0, b1, b2]; | |
var a = 0; | |
var b = 0; |