Solution using HashMap✅✅
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int beautifulSubsets(int[] nums, int k) {\n        int ans = subset(nums,0,k,new HashMap<Integer,Integer>());\n        return ans-1;\n    }\n    private int subset(int[] nums, int index,int k, HashMap<Integer,Integer> map){\n        if(index == nums.length) return 1;\n        int taken = 0;\n        if(!map.containsKey(nums[index] -k) && !map.containsKey(nums[index] +k)){\n            map.put(nums[index],map.getOrDefault(nums[index],0)+1);\n            taken = subset(nums,index+1,k,map);\n            map.put(nums[index],map.get(nums[index])-1);\n            if(map.get(nums[index]) == 0){\n                map.remove(nums[index]);\n            }\n        }\n        int nottaken = subset(nums,index+1,k,map);\n        return taken + nottaken;\n    }\n}\n```
['Java']