Subarray Division 2

  • + 0 comments

    My rust solution:

    fn birthday(s: &[i32], d: i32, m: i32) -> i32 {
        let m = m as usize;
        (0..s.len())
            .filter(|&i| i + m <= s.len())
            .filter(|&i| s[i..i + m].iter().sum::<i32>() == d)
            .count() as i32
    }