Given an array nums, return the number of subsequences with an odd sum of elements.
Since the answer may be very large, return it modulo 109 + 7.
Example 1:
Input: nums = [1,1,1]
Output: 4
Explanation:
The odd-sum subsequences are: [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1].
Example 2:
Input: nums = [1,2,2]
Output: 4
Explanation:
The odd-sum subsequences are: [1, 2, 2], [1, 2, 2], [1, 2, 2], [1, 2, 2].
Constraints:
1 <= nums.length <= 1051 <= nums[i] <= 109dp[i][0] as the answer for the subarray [0, i].dp[i][1] as the answer for the subarray [0, i] if we wanted to count even-sum subsequences.nums[i] is odd, dp[i][x] = 2i.dp[i][x] = dp[i - 1][x] * 2.dp[0][1] = 1 if nums[0] is odd, and 0 otherwise.dp[0][0] = 2 if nums[0] is even, and 1 otherwise (since an empty subsequence has an even sum).[1,1,1]
[1,2,2]