Tap here to switch tabs
Problem
Submissions

Problem: Count of Sub-Multisets With Bounded Sum

med
30 min
Try to solve the Count of Sub-Multisets With Bounded Sum problem.

Statement

Given an array of non negative integers nums and two integers l and r, compute the number of sub multisets of nums whose sum of elements falls within the range [[l, r]] inclusive.

Since the result may be very large, return it modulo 109+710^9 + 7.

Note: A sub multiset is an unordered collection of elements from nums where the frequency of each element does not exceed its frequency in nums. The sum of an empty sub multiset is 00.

Constraints:

  • 1≤1 \leq nums.length ≤2imes104\leq 2 imes 10^4

  • 0≤0 \leq nums[i] ≤2imes104\leq 2 imes 10^4

  • The sum of all elements in nums does not exceed 2imes1042 imes 10^4

  • 0≤0 \leq l ≤\leq r ≤2imes104\leq 2 imes 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count of Sub-Multisets With Bounded Sum

med
30 min
Try to solve the Count of Sub-Multisets With Bounded Sum problem.

Statement

Given an array of non negative integers nums and two integers l and r, compute the number of sub multisets of nums whose sum of elements falls within the range [[l, r]] inclusive.

Since the result may be very large, return it modulo 109+710^9 + 7.

Note: A sub multiset is an unordered collection of elements from nums where the frequency of each element does not exceed its frequency in nums. The sum of an empty sub multiset is 00.

Constraints:

  • 1≤1 \leq nums.length ≤2imes104\leq 2 imes 10^4

  • 0≤0 \leq nums[i] ≤2imes104\leq 2 imes 10^4

  • The sum of all elements in nums does not exceed 2imes1042 imes 10^4

  • 0≤0 \leq l ≤\leq r ≤2imes104\leq 2 imes 10^4