• + 5 comments

    Same approach in C#

    int total = 0;
    for(int i = 0; i <= s.Count - m; i++) {
        var segsSum = s.GetRange(i, m).Aggregate((a, b) => a + b);
        if(segsSum == d) {
           total++;
        }
    }
    return total;