We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
// Complete the birthday function below.
static int birthday(List<Integer> s, int d, int m) {
int length = s.size();
int numWays = 0, sum = 0;
for(int i = 0 ; i <= (length - m) ; i++){
for(int j = 0 ; j < m ; j++){
sum = sum + s.get(j+i);
}
if(sum == d){
numWays++;
}
sum = 0;
}
return numWays;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Subarray Division
You are viewing a single comment's thread. Return to all comments →
Very simple to understand solution.