Easiest C++ Solution || Best Approach🔥
\nVideo Solution-> https://youtu.be/XdV6XtwwDEU?si=qRGQmqg1GwPnuQQE\n\n# Complexity\n- Time complexity:O(2^n)\n Add your time complexity here, e.g. O(n) \n\n- S
\nVideo Solution-> https://youtu.be/XdV6XtwwDEU?si=qRGQmqg1GwPnuQQE\n\n# Complexity\n- Time complexity:O($$2^n$$)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O($$n$$)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int solve(vector<int>& nums, int k, int i, int n, unordered_map<int,int> &mp){\n\n        if(i>=n) return 1;\n\n        int notTake = solve(nums,k,i+1,n,mp);\n\n        int take = 0;\n        if(mp[nums[i]-k]==0 && mp[nums[i]+k]==0){\n            mp[nums[i]]++;\n            take = solve(nums,k,i+1,n,mp);\n            mp[nums[i]]--;\n        }\n\n        return take + notTake;\n        \n    }\n    int beautifulSubsets(vector<int>& nums, int k) {\n        \n        int n = nums.size();\n        unordered_map<int,int> mp;\n\n        int ans = solve(nums,k,0,n, mp);\n\n        return ans-1;\n    }\n};\n\n\n\n```
['C++']