dp with bitmasking c++
\nclass Solution {\npublic:\n    vector<int> smallestSufficientTeam(vector<string>& req, vector<vector<string>>& people) {\n        \n        unordered_map<stri
```\nclass Solution {\npublic:\n    vector<int> smallestSufficientTeam(vector<string>& req, vector<vector<string>>& people) {\n        \n        unordered_map<string,int> skill;\n        int n = req.size();\n        \n        for(int i=0;i<n;i++){\n            skill[req[i]] = i;\n        }\n        \n        int m = people.size();\n        vector<int> score(m,0);\n        \n        // calculating mask for each team\n        \n        for(int i=0;i<m;i++){\n            int mask = 0;\n            for(auto j:people[i]){\n                mask = mask | (1<<skill[j]);\n            }\n            score[i] = mask;\n        }\n        \n        int target = (1<<n)-1;\n        \n        vector<int> dp(1<<n,INT_MAX);\n        vector<vector<int>> ans(1<<n,vector<int>());\n        \n        dp[0] = 0;\n        \n        for(int mask=0;mask<(1<<n);mask++){\n            \n            if(dp[mask] == INT_MAX)continue;  // means this state cannot be reached\n            \n            for(int j=0;j<m;j++){\n                \n                int nmask = mask | score[j];\n                \n                if(1 + dp[mask] < dp[nmask]){     // if new state can be reached\n                    dp[nmask] = 1 + dp[mask];\n                    ans[nmask] = ans[mask];       // then add all teams included in old state\n                    ans[nmask].push_back(j);      // add new team also\n                }\n                \n            }\n            \n        }\n        \n     return ans[target];\n    }\n};\n```
['Dynamic Programming', 'C', 'Bitmask']