Python3 Solution
\n\nclass Solution:\n    def beautifulSubsets(self, nums: List[int], k: int) -> int:\n        count=Counter(nums)\n        def dp(num):\n            dp0,dp1=dp(
\n```\nclass Solution:\n    def beautifulSubsets(self, nums: List[int], k: int) -> int:\n        count=Counter(nums)\n        def dp(num):\n            dp0,dp1=dp(num-k) if num-k in count else (1,0)\n            return dp0+dp1, dp0*(pow(2,count[num])-1)\n        return reduce(mul,(sum(dp(num)) for num in count if not count[num+k]  ))-1\n```
['Python', 'Python3']