← ALL NOTES
Array

1524. Number of Sub-arrays With Odd Sum

Count contiguous subarrays with odd sum, mod 1e9+7. A subarray's sum is prefix[r] − prefix[l], which is odd iff the two prefix sums have opposite parity — so for each prefix, the number of valid…

Loading…