Basic intuitive solution with brute force approach C++ ✅✅
I have added comments in the code itself to understand the logic so not writing much description.\n\nThis problem uses simple backtracking technique with recurs
I have added comments in the code itself to understand the logic so not writing much description.\n\nThis problem uses simple backtracking technique with recursion. See the below C++ code\n\n```\nclass Solution {\n    void util(vector<int>& nums, int &k,vector<int> &v,int ind,int &ans){\n        if(ind==nums.size()){//if reached the end\n            if(v.size()!=0)//and the vector is non-empty\n                ans++;//increase the answer\n            return;\n        }\n        //for current index add it to vector\n        v.push_back(nums[ind]);\n        //and if the resultant vector is beautiful\n        if(beautiful(v,k))\n            util(nums,k,v,ind+1,ans); //try adding further elements\n        //if not remove the current element as adding further elements in this vector will also be non-beautiful\n        v.pop_back();\n        //and procede with adding remaining elements\n        util(nums,k,v,ind+1,ans); \n    }\n    //basic function which checks if the given array is beautiful or not\n    bool beautiful(vector<int>&v,int k){\n        //this function tries out all possible combinations and if anyone of them has an absolute difference of k we return false and true otherwise\n        for(int i=0;i<v.size();i++){\n            for(int j=i+1;j<v.size();j++){\n                if(abs(v[i]-v[j])==k)\n                    return false;\n            }\n        }\n        return true;\n    }\npublic:\n    int beautifulSubsets(vector<int>& nums, int k) {\n        vector<int> v;\n        int ans = 0;\n        util(nums,k,v,0,ans);\n        return ans;\n    }\n};\n```
[]