Skip to content

Practice The Number of Good Subsets

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

Problem Statement

You are given an integer array nums. We call a subset of nums good if its product can be represented as a product of one or more distinct prime numbers. Return the number of different good subsets in nums modulo 10^9 + 7. A subset of nums is any array that can be obtained by deleting some (possibly none or all) elements from nums. Two subsets are different if and only if the chosen indices to delete are different.

Source: The Number of Good Subsets on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,2,3,4]
Output
6

# Example 2

Input
nums = [4,2,3,15]
Output
5

Constraints

1 <= nums.length <= 10^5
1 <= nums[i] <= 30

Related LeetCode Problems

Practice more problems similar to The Number of Good Subsets.

Review your practice with PhantomCodeAI

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