🎆CPP Self Explainatory Code with comments at each step || Recursion || BitMasking || Memoization
\n# Code\n\nclass Solution {\npublic:\n    int choices[1<<16][60];\n    int dp[1<<16][60];\n\n    int helper(vector<int> &p,int ind,int curr_mask,int reqd_mask)
\n# Code\n```\nclass Solution {\npublic:\n    int choices[1<<16][60];\n    int dp[1<<16][60];\n\n    int helper(vector<int> &p,int ind,int curr_mask,int reqd_mask){\n        //base cases:\n        if(curr_mask==reqd_mask)return 0;\n        if(ind==p.size()) return 1e6;\n        if(dp[curr_mask][ind]!=-1)return dp[curr_mask][ind];\n\n        //two options for each index: take or notTake:\n        int temp1=helper(p,ind+1,curr_mask,reqd_mask);\n        int temp2=1+helper(p,ind+1,curr_mask | p[ind],reqd_mask);\n\n        //if taking the current index is beneficial for us, we mark the\n        //index as 1 in the choices, with the curr_mask as the mask needed;\n        if(temp2<temp1) choices[curr_mask][ind]=1;\n\n        //return the minimum no of people reqd for the job:\n        return dp[curr_mask][ind]=min(temp1,temp2);\n    }\n\n    vector<int> smallestSufficientTeam(vector<string>& req_skills, vector<vector<string>>& people){\n        memset(choices,0,sizeof(choices));\n        memset(dp,-1,sizeof(dp));\n\n        int n=req_skills.size();\n        int m=people.size();\n\n        //converting the skills from the reqd_skills into the \n        //no of bits 1 needs to be left-shifted in order to access it;\n        unordered_map<string,int> skills;\n        for(int i=0;i<n;i++)skills[req_skills[i]]=i;\n\n        //converting the skills that the ith person has into bits;\n        vector<int> p;\n        for(auto v:people){\n            int total_skills=0;\n            for(auto str:v){\n                total_skills |= (1<<skills[str]);\n            }\n            p.push_back(total_skills);\n        }\n\n        int reqd_mask=(1<<n)-1;\n        helper(p,0,0,reqd_mask);\n\n        //choose the beneficial indices with inital mask as 0 and \n        //push them into the out vector;\n        vector<int> out;\n        int mask=0;     //represents no people(thus no skills) at the beginning\n        for(int i=0;i<m;i++){\n            if(choices[mask][i]){\n                mask |= p[i];\n                out.push_back(i);\n            }\n        }\n        return out;\n    }\n};\n```\n![upvote xd.jpeg](https://assets.leetcode.com/users/images/aff020b8-a5b3-4f22-807d-73c0114a9b81_1689521122.1293895.jpeg)\n
['Recursion', 'Memoization', 'Bitmask', 'C++']