[Python] HashMap + Knapsack dfs
\t\tdef beautifulSubsets(self, nums: List[int], k: int) -> int:\n\t\t\tn = len(nums)\n\t\t\tres = 0\n\t\t\tcntMap = defaultdict(int)\n\n\t\t\tdef dfs(i):\n\t\t\
\t\tdef beautifulSubsets(self, nums: List[int], k: int) -> int:\n\t\t\tn = len(nums)\n\t\t\tres = 0\n\t\t\tcntMap = defaultdict(int)\n\n\t\t\tdef dfs(i):\n\t\t\t\tnonlocal res,cntMap\n\t\t\t\tif i==n :\n\t\t\t\t\tres += 1\n\t\t\t\t\treturn \n\t\t\t\tnum = nums[i]\n\t\t\t\t# include the curr num\n\t\t\t\tif cntMap[num-k] == 0 and cntMap[num+k] == 0 :  # check if diff k number is already in our set or not\n\t\t\t\t\tcntMap[num] += 1  # add the num in set\n\t\t\t\t\t\tdfs(i+1)  \n\t\t\t\t\tcntMap[num] -= 1  # remove the num from set\n\t\t\t\t# exclude the curr num\n\t\t\t\tdfs(i+1)   \n\n\t\t\tdfs(0)\n\t\t\treturn res-1   # -1 for empty set\n
[]