Created
January 16, 2022 17:30
-
-
Save see-why/b8582769f6d4b1cc58d21cad55c090ed to your computer and use it in GitHub Desktop.
HackerRank SubArray Division Challenge
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 birthday(s, d, m) { | |
// Write your code here | |
let count = 0; | |
s.map((item, index) => { | |
let sum = item; | |
for (let i=index+1; i < (index+m) ; i++ ){ | |
if (i < s.length){ | |
sum += s[i]; | |
} | |
} | |
if (sum == d){ | |
count++; | |
} | |
}) | |
return count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment