Java solution using Recursion
Code\n\nclass Solution {\n    public int beautifulSubsets(int[] nums, int k) {\n        ArrayList<Integer> arr = new ArrayList<>();\n        return beautiful(nu
# Code\n```\nclass Solution {\n    public int beautifulSubsets(int[] nums, int k) {\n        ArrayList<Integer> arr = new ArrayList<>();\n        return beautiful(nums, k , 0,arr);\n    }\n\n    int beautiful(int[] nums, int k , int index,ArrayList<Integer> arr){\n        if(index == nums.length){\n            return 0;\n        }\n\n        int take = 0;\n        if(takeable(arr,nums[index], k)){\n            arr.add(nums[index]);\n            take = 1 + beautiful(nums, k, index+1,arr);\n            arr.remove(arr.size()-1);\n        }\n\n        int notTake = 0 + beautiful(nums, k, index+1,arr);\n\n        return take + notTake;\n        \n    }\n\n    boolean takeable(ArrayList<Integer> arr, int num, int k){\n        for(int ele : arr){\n            if(Math.abs(num - ele) == k) return false;\n        }\n\n        return true;\n    }\n}\n```
['Recursion', 'Java']