Java Solution using Recursion by generating all valid subsets
Code\n\nclass Solution {\n    int count=0;\n    private void f(int ind,int []nums,int k,ArrayList<Integer> temp)\n    {\n        if(ind==nums.length)\n        {
# Code\n```\nclass Solution {\n    int count=0;\n    private void f(int ind,int []nums,int k,ArrayList<Integer> temp)\n    {\n        if(ind==nums.length)\n        {\n            count++;\n            return;\n        }\n        f(ind+1,nums,k,temp);\n\n        boolean isNotPossible=false;\n        for(Integer num:temp)\n        {\n            if(Math.abs(num-nums[ind])==k)\n            {\n                isNotPossible=true;\n                break;\n            }\n        }\n        if(!isNotPossible)\n        {\n            temp.add(nums[ind]);\n            f(ind+1,nums,k,temp);\n            temp.remove(temp.size()-1);\n        }      \n    }\n\n    public int beautifulSubsets(int[] nums, int k) {\n        ArrayList<Integer> temp=new ArrayList<>();\n        f(0,nums,k,temp);\n        return count-1;\n    }\n}\n```
['Array', 'Dynamic Programming', 'Backtracking', 'Recursion', 'Sorting', 'Java']