Accepted solution

Birthday Chocolate(Hacker Rank)

Open original problem
Source code

// Complete the birthday function below.

int birthday(vector<int> s, int d, int m)

{

    int count=0;

    for(int i =0;i<s.size();i++)

    {

        int sum =0;

        for(int j=i;j<i+m;j++)

        {

           sum+=s[j];

        }

        if(sum==d)

        {

            count++;

        }

    }

   return count;

}
Join the discussion

Add your comment