c++ | DP | Back Tracking
\n//bitmasking + dp\n\nclass Solution {\npublic:\n    \n    int dp[1<<16][61];\n    map<string,int> skill_index;\n    int req_Skills_size;\n    vector<int> resu
```\n//bitmasking + dp\n\nclass Solution {\npublic:\n    \n    int dp[1<<16][61];\n    map<string,int> skill_index;\n    int req_Skills_size;\n    vector<int> result;\n    \n    int getUpdateMask(int mask, vector<string> skills) {\n        int length = skills.size();\n        for(int i=0;i<length;i++) {\n            int idx = skill_index[skills[i]];\n            mask |= (1<<idx);\n        }\n        return mask;\n    }\n  \n    int solve(int idx, int mask,vector<vector<string>>& people) {\n       if(mask == (1<<req_Skills_size)-1){\n            dp[mask][idx] =0;\n            return 0;\n        }\n        if(idx >= people.size()) return  people.size()+1;\n        else if(mask == (1<<req_Skills_size)-1){\n            dp[mask][idx] =0;\n            return 0;\n        }\n        else if(dp[mask][idx] !=-1) return dp[mask][idx];\n        else {\n            int ans = solve(idx+1,mask,people);\n            int newMask = getUpdateMask(mask, people[idx]);\n            ans = min(ans, solve(idx+1, newMask,people)+1);\n            dp[mask][idx] = ans;\n            return ans ;\n        }\n    }\n    \n    void backtrack(int mask,int idx,vector<vector<string>>& people) {\n         if(mask == (1<<req_Skills_size)-1) return ;\n          else {\n              int nm = getUpdateMask(mask,people[idx]);\n             // cout<<idx<<" -- "<<dp[mask][idx]<< " -- " <<dp[nm][idx+1]+1<<endl;\n              if(idx == people.size()-1 || dp[mask][idx] == dp[nm][idx+1]+1) {\n                  result.push_back(idx);\n                  backtrack(nm,idx+1,people);\n              }\n              else {\n                    backtrack(mask,idx+1,people);\n              }\n          }\n    }\n    \n    vector<int> smallestSufficientTeam(vector<string>& req_skills, vector<vector<string>>& people) {\n        \n        req_Skills_size = req_skills.size();\n        \n        int maxi = 1<<req_Skills_size;\n        \n        for(int i=0;i<maxi;i++) {\n            for(int j=0;j<=60;j++) {\n                dp[i][j] =-1;\n            }\n        }\n        \n        for(int i=0;i<req_Skills_size;i++) {\n            skill_index[req_skills[i]] = i;    \n        }\n        \n        cout<<solve(0,0,people)<<endl;\n        backtrack(0,0,people);\n        return result;\n        \n    }\n};\n```
[]