Skip to content

Instantly share code, notes, and snippets.

@see-why
Created January 16, 2022 17:30
Show Gist options
  • Save see-why/b8582769f6d4b1cc58d21cad55c090ed to your computer and use it in GitHub Desktop.
Save see-why/b8582769f6d4b1cc58d21cad55c090ed to your computer and use it in GitHub Desktop.
HackerRank SubArray Division Challenge
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