Simple Backtracking | C++
\nclass Solution {\n    int dfs(int i, int n, vector<int> &v, vector<int> &nums, int k) {\n        if(i == n) return 1;\n        \n        int notPick = dfs(i +
```\nclass Solution {\n    int dfs(int i, int n, vector<int> &v, vector<int> &nums, int k) {\n        if(i == n) return 1;\n        \n        int notPick = dfs(i + 1, n, v, nums, k), pick = 0;\n        int f = 0;\n        for(int j : v) {\n            if(abs(j - nums[i]) == k) {\n                f = 1;\n                break;\n            }\n        }\n        if(!f) {\n            v.push_back(nums[i]);\n            pick = dfs(i + 1, n, v, nums, k);\n            v.pop_back();\n        }\n        return pick + notPick;\n    }\npublic:\n    int beautifulSubsets(vector<int>& nums, int k) {\n        int n = nums.size();\n        vector<int> v;\n        return dfs(0, n, v, nums, k) - 1;\n    }\n};\n```
['Backtracking', 'C++']