Skip to content

Practice Number of Ways to Earn Points

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#2585
LeetCode Problem

Number of Ways to Earn Points

Problem Statement

There is a test that has n types of questions. You are given an integer target and a 0-indexed 2D integer array types where types[i] = [counti, marksi] indicates that there are counti questions of the ith type, and each one of them is worth marksi points. Return the number of ways you can earn exactly target points in the exam. Since the answer may be too large, return it modulo 10^9 + 7. Note that questions of the same type are indistinguishable.

Source: Number of Ways to Earn Points on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
target = 6, types = [[6,1],[3,2],[2,3]]
Output
7

# Example 2

Input
target = 5, types = [[50,1],[50,2],[50,5]]
Output
4

# Example 3

Input
target = 18, types = [[6,1],[3,2],[2,3]]
Output
1

Constraints

1 <= target <= 1000
n == types.length
1 <= n <= 50
types[i].length == 2
1 <= counti, marksi <= 50

Related LeetCode Problems

Practice more problems similar to Number of Ways to Earn Points.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.