LeetCode 1524, Medium. Topics: Array, Math, Dynamic Programming, Prefix Sum. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 19 parametrized pytest cases, and a playground notebook:
Problem
<p>Given an array of integers <code>arr</code>, return <em>the number of subarrays with an <strong>odd</strong> sum</em>.</p>
<p>Since the answer can be very large, return it modulo <code>10<sup>9</sup> + 7</code>.</p>
Examples
Constraints
- 1 <= arr.length <= 10^5
- 1 <= arr[i] <= 100
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
NeetCode All. Last modified on September 7, 2026