890. Number of Subsequences with Odd Sum

Given an integer array nums, return the number of subsequences whose sum of elements is odd.

Since the answer may be very large, return it modulo 109 + 7.

Example 1:

Input: nums = [3, 3, 3]

Output: 4

Explanation: The subsequences with an odd sum are: [3], [3], [3], [3, 3, 3].

Example 2:

Input: nums = [2, 5, 6]

Output: 4

Explanation: The subsequences with an odd sum are: [5], [2, 5], [5, 6], [2, 5, 6].

Now Your Turn!

Pick the correct output for the given input

Input: nums = [4, 7, 9]

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= nums.length <= 105
  • 1 <= nums[i] <= 109

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

0
class Solution {
public:
int subsequenceCount(vector<int>& nums) {
}
};
Test Case

Input:

Nums