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.
static int birthday(List<Integer> s, int d, int m) {
int sum = 0,ways=0;
for (int i=0;i<m;i++){
sum += s.get(i);
}
for (int i=0;i<s.size()-m+1;i++) {
if (sum==d) {
ways++;
}
if (i+m <s.size()){
sum =sum-s.get(i)+s.get(i+m);
}
}
return ways;
}
Subarray Division
You are viewing a single comment's thread. Return to all comments →