Solution by saey anime is here
Intuition\n Describe your first thoughts on how to solve this problem. \nSimply generate all subsets(O(2^n)). Including and excluding but including only when it
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSimply generate all subsets(O(2^n)). Including and excluding but including only when it\'s absolute difference is not k with any of the elements(O(n)) time.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nIt\'s top-down approach. Just include and exclude every element. Generate all valid subsets and count them.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(2^n * (n))\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(n) + stack space\n\n# Code\n```\n<!-- top down approach(O(2^n * (n))) time. -->\nclass Solution {\n    int res;\n\n    private void f1(ArrayList<Integer> temp, int[] nums, int i, int n, int k) {\n        if(i == n) {\n            res++;\n            return;\n        } else {\n            boolean flag = true;\n            for(int t: temp) {\n                if(Math.abs(t-nums[i]) == k) {\n                    flag = false;\n                    break;\n                }\n            }\n            if(flag) {\n                temp.add(nums[i]);\n                f1(temp, nums, i+1, n, k);\n                temp.remove(temp.size()-1);\n            }\n            f1(temp, nums, i+1, n, k);\n        }\n    }\n\n    public int beautifulSubsets(int[] nums, int k) {\n        res = 0;\n        f1(new ArrayList<>(), nums, 0, nums.length, k);\n        return res-1;\n    }\n}\n```
['Java']