DEV Community

duccanhole
duccanhole

Posted on

4 1

code everyday with me

--DAY 10--

Hi, I am going to make #100DaysOfCode Challenge. Everyday I will try solve 1 problem from leetcode or hackerrank. Hope you can go with me until end.
Now let's solve problem today:
-Problem: Subarray Division
-Detail: https://www.hackerrank.com/challenges/the-birthday-bar/problem
-My solution (javascript):

function birthday(arr, d, m) {
    let ans=0,s=0;
    for(let i=0;i<arr.length;i++){
        for(let j=i;j<(i+m);j++) s+=arr[j];
        if(s==d) ans++;
        s=0;
    }
    return ans;
}
Enter fullscreen mode Exit fullscreen mode

-->If you have better solution or any question, please comment below. I will appreciate.

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay