Python solution
\n\n# Code\n\nclass Solution:\n    def beautifulSubsets(self, nums: List[int], k: int) -> int:\n        nums.sort()\n        n = len(nums)\n        count = 0\n 
\n\n# Code\n```\nclass Solution:\n    def beautifulSubsets(self, nums: List[int], k: int) -> int:\n        nums.sort()\n        n = len(nums)\n        count = 0\n        \n        def backtrack(start, current_set):\n            nonlocal count\n            if current_set:\n                count += 1\n            for i in range(start, n):\n                if all(abs(nums[i] - x) != k for x in current_set):\n                    current_set.append(nums[i])\n                    backtrack(i + 1, current_set)\n                    current_set.pop()\n\n        backtrack(0, [])\n        return count\n\n```
['Backtracking', 'Python3']