✅ Java | Easy | Backtracking
\nclass Solution {\n    public int beautifulSubsets(int[] nums, int k) {\n        Arrays.sort(nums);\n        List<List<Integer>> res=new ArrayList<>();\n      
```\nclass Solution {\n    public int beautifulSubsets(int[] nums, int k) {\n        Arrays.sort(nums);\n        List<List<Integer>> res=new ArrayList<>();\n        f(0,nums,res,new ArrayList<>(),k);\n        return res.size();\n    }\n    public void f(int ind,int[] nums,List<List<Integer>> res,List<Integer> ds,int k){\n        if(ind==nums.length){\n            if(ds.size()>0){\n                res.add(new ArrayList<>(ds));\n            }\n            return;\n        }\n        if(!(ds.contains(nums[ind]-k) )){\n            ds.add(nums[ind]);\n            f(ind+1,nums,res,ds,k);    \n            ds.remove(ds.size()-1);\n        }\n        f(ind+1,nums,res,ds,k);\n    }\n}\n```\n![image](https://assets.leetcode.com/users/images/88b661ea-460f-4fae-9300-74c926917f1b_1679201217.682688.png)\n\n![image](https://assets.leetcode.com/users/images/731b8eb1-00ef-4c65-9c08-35b45cd15cf5_1679201138.4363368.jpeg)\n
['Backtracking', 'Depth-First Search', 'Recursion', 'Java']