
[LeetCode] 1524. Number of Sub-arrays With Odd Sum (Python)
·
알고리즘/LeetCode
난이도: MediumProblem DescriptionGiven an array of integers arr, return the number of subarrays with an odd sum. Since the answer can be very large, return it modulo 109 + 7. Problem ExampleExample 1:Input: arr = [1,3,5]Output: 4Explanation: All subarrays are [[1],[1,3],[1,3,5],[3],[3,5],[5]]All sub-arrays sum are [1,4,9,3,8,5].Odd sums are [1,9,3,5] so the answer is 4.Example 2:Input: arr = [2,4,..