Practice The Number of Beautiful Subsets
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
The Number of Beautiful Subsets
Problem Statement
You are given an array nums of positive integers and a positive integer k. A subset of nums is beautiful if it does not contain two integers with an absolute difference equal to k. Return the number of non-empty beautiful subsets of the array nums. A subset of nums is an array that can be obtained by deleting some (possibly none) elements from nums. Two subsets are different if and only if the chosen indices to delete are different.
Source: The Number of Beautiful Subsets on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [2,4,6], k = 2
4
# Example 2
nums = [1], k = 1
1
Constraints
Related LeetCode Problems
Practice more problems similar to The Number of Beautiful Subsets.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.