DP bitmasking | C++
\nclass Solution {\npublic:\n    \n    int findAns(unordered_map<string, int> & req_skills, vector<vector<int>> & people, int *** dp, int n, int len, int start,
```\nclass Solution {\npublic:\n    \n    int findAns(unordered_map<string, int> & req_skills, vector<vector<int>> & people, int *** dp, int n, int len, int start, int mask){\n        if(mask==0){\n            return 0;\n        }\n        if(start==len){\n            return 10000;\n        }\n        \n        if(dp[mask][start][0]!=-1){\n            return min(dp[mask][start][0], dp[mask][start][1]);\n        }\n        \n        int op1 = findAns(req_skills, people, dp, n, len, start+1, mask);\n        int op2 = 1;\n        int org_mask = mask;\n        for(int i=0;i<people[start].size();i++){\n            int ind = people[start][i];\n            mask = (mask&(~(1<<ind)));\n        }\n        op2+=findAns(req_skills, people, dp, n, len, start+1, mask);\n        \n        dp[org_mask][start][0] = op1;\n        dp[org_mask][start][1] = op2;\n        dp[org_mask][start][2] = org_mask;\n        dp[org_mask][start][3] = mask;\n        return min(op1, op2);\n        \n        \n    }\n    \n    vector<int> smallestSufficientTeam(vector<string>& req_skills, vector<vector<string>>& people) {\n        \n        vector<int> ans;\n        int n = req_skills.size();\n        int pown = 1<<n;\n        int len = people.size();\n        int*** dp = new int**[pown];\n        \n        for(int i=0;i<pown;i++){\n            dp[i] = new int*[len];\n            for(int j=0;j<len;j++){\n                dp[i][j] = new int[4];\n                dp[i][j][0] = -1;\n                dp[i][j][1] = -1;\n                dp[i][j][2] = -1;\n                dp[i][j][3] = -1;\n            }\n        }\n        unordered_map<string, int> map;\n        for(int i=0;i<req_skills.size();i++){\n            map[req_skills[i]] = i;\n\n        }\n        \n        vector<vector<int>> v;\n        for(int i=0;i<len;i++){\n            vector<int> v1;\n            for(int j=0;j<people[i].size();j++){\n                string s = people[i][j];\n                if(map.find(s)==map.end()){\n                    v1.push_back(-1);\n                }\n                else{\n                    v1.push_back(map[s]);\n                }\n            }\n            \n            v.push_back(v1);\n        }\n        \n        findAns(map, v, dp, n, len, 0, pown-1);\n       \n        \n        int mask = pown-1;\n        int i = 0;\n        while(mask!=0 and i<len){\n            if(dp[mask][i][0]<dp[mask][i][1]){\n                i++;\n            }\n            else{\n                ans.push_back(i);\n                mask = dp[mask][i][3];\n                i++;\n            }\n        }\n        return ans;\n        \n    }\n};\n```
[]