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.
public static int birthday(List<Integer> s, int d, int m) {
// Write your code here
int segments = 0;
int n = s.size();
for(int i = 0; i <= n-m; i++){
int sum =0;
for(int j = 0; j < m ; j++){
sum = sum + s.get(i + j);
}
if(sum == d){
segments++;
}
}
return segments;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Subarray Division 2
You are viewing a single comment's thread. Return to all comments →