Tap here to switch tabs
Problem
Submissions

Problem: The Number of Beautiful Subsets

med
30 min
Try to solve the 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 considered beautiful if it does not contain any pair of elements with an absolute difference equal to k.

Return the total number of non empty beautiful subsets of nums.

Note: A subset is formed by deleting zero or more elements from nums. Two subsets are distinct if they are chosen from different indices of nums.

Constraints:

  • 1≤1 \leq nums.length ≤18\leq 18

  • 1≤1 \leq nums[i], k ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: The Number of Beautiful Subsets

med
30 min
Try to solve the 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 considered beautiful if it does not contain any pair of elements with an absolute difference equal to k.

Return the total number of non empty beautiful subsets of nums.

Note: A subset is formed by deleting zero or more elements from nums. Two subsets are distinct if they are chosen from different indices of nums.

Constraints:

  • 1≤1 \leq nums.length ≤18\leq 18

  • 1≤1 \leq nums[i], k ≤1000\leq 1000