1524. Number of Sub-arrays With Odd Sum
Содержание
class Solution:
def numOfSubarrays(self, arr: List[int]) -> int:
mod = 10**9 + 7
cnt = [1, 0]
res = s = 0
for x in arr:
s += x
res = (res + cnt[s & 1 ^ 1]) % mod
cnt[s & 1] += 1
return res