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<int> s, int d, int m) {
int sumCount = 0;
int sLength = s.Count;
if (m <= sLength) {
int curSum = 0;
for (int j=0; j<m; j++) {
curSum += s[j];
}
if (curSum == d) {
sumCount++;
}
for (int j=m; j<sLength; j++) {
curSum += s[j] - s[j-m];
if (curSum == d) {
sumCount++;
}
}
}
return sumCount;
}
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 →
My C# solution: