[JavaScript & C++] - Easy Solutions
JavaScript\n\n/**\n * @param {number[]} nums\n * @param {number} k\n * @return {number}\n */\nvar beautifulSubsets = function(nums, k) {\n    const helper = arr
# JavaScript\n```\n/**\n * @param {number[]} nums\n * @param {number} k\n * @return {number}\n */\nvar beautifulSubsets = function(nums, k) {\n    const helper = arr => {\n        let len = arr.length;\n        if (len === 0) return 0;\n        let res = 0;\n        for(let i = 0; i < len; i++) {\n            let next = [];\n            for (let j = i + 1; j < len; j++) {\n                if (Math.abs(arr[i] - arr[j]) !== k) {\n                    next.push(arr[j]);\n                }\n            }\n            res += 1 + helper(next);\n        }\n        return res;\n    }\n\n    return helper(nums)\n};\n```\n\n# C++\n```\nclass Solution {\npublic:\n    map<int, int> cand;\n    int ans = 0;\n\n    void generate(vector<int>& nums, int k, int i)\n    {\n        if(i == nums.size())\n        {\n            //If all elements of the set have already been considered\n            ans++;\n        }\n        else \n        {\n            //If possible (ragarding the constraint) include the current element into the set\n            int l = cand.size();\n            if(l == 0 || cand[nums[i]-k] == 0 && cand[nums[i]+k] == 0)\n            {\n                cand[nums[i]]++;\n                generate(nums, k, i+1);\n                cand[nums[i]]--;\n            }\n\n            //Do NOT include the current element into the set\n            generate(nums, k, i+1);\n        }\n    }\n\n    int beautifulSubsets(vector<int>& nums, int k) \n    {\n        generate(nums, k, 0);\n        return ans - 1;   \n    }\n};\n```
['Array', 'Backtracking', 'Ordered Map', 'C++', 'JavaScript']