Easy Java Solution || Beginner Friendly || 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        Map<Integer,Integer> map = new HashMap<>();\n        return helper(nums,k,map,0,0)-1;\n    }\n    public int helper(int[] nums,int k,Map<Integer,Integer> map,int ind,int count){\n        if(ind==nums.length){\n            count++;\n            return count;\n        }\n\n        int n = nums[ind];\n        int take = 0;\n        if(!map.containsKey(n+k)&&!map.containsKey(n-k)){\n            map.put(n,map.getOrDefault(n,0)+1);\n            take = helper(nums,k,map,ind+1,count);\n            map.put(n,map.get(n)-1);\n            if(map.get(n)==0){\n                map.remove(n);\n            }\n        }\n        int notTake = helper(nums,k,map,ind+1,count);\n        return take+notTake;\n    }\n}\n```
['Java']