Talentd/FleetCode/Problems/

3247. Number of Subsequences with Odd Sum

Medium
Read SolutionWatch Video

3247. Number of Subsequences with Odd Sum

Medium47.6% AcceptancePremium
PremiumFree on FleetCode

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 <= 105
  • 1 <= nums[i] <= 109

Loading editor...

[1,1,1]