You are given a list of positive integers nums and a positive integer k.
We call a subset beautiful if no two numbers inside it differ by exactly k.
Your task is to determine how many non-empty beautiful subsets can be formed from nums.
A subset is formed by choosing any combination of elements while keeping their original index distinctions. Two subsets are counted as different if they correspond to different index selections.
Input: nums = [3, 5, 8, 10], k = 2
Output: 8
Explanation:
Valid beautiful subsets include: [3], [5], [8], [10], [3,8], [3,10], [5,8], [5,10], [8,10], [3,5,8], [3,8,10] (For example, [3,5] is invalid because |3 - 5| = 2 = k.)
Input: nums = [4, 7, 9], k = 3
Output: 5
Explanation:
Beautiful subsets: [4], [7], [9], [4,9], [7,9]
Accepted:
Submission: