[ C++ ] [ DP ]
Code\n\nclass Solution {\npublic:\n    vector<int> smallestSufficientTeam(vector<string>& req_skills, vector<vector<string>>& people) {\n        int n = (int)re
# Code\n```\nclass Solution {\npublic:\n    vector<int> smallestSufficientTeam(vector<string>& req_skills, vector<vector<string>>& people) {\n        int n = (int)req_skills.size();\n        unordered_map<int, vector<int>> dp;\n        unordered_map<string, int> skill_idx;\n        dp.reserve(1 << n);\n        dp[0] = {};\n\n        for (int i = 0; i < n; i++) {\n            skill_idx[req_skills[i]] = i;\n        }\n\n        for (int i = 0; i < (int)people.size(); i++) {\n            int curr_skill = 0;\n            for (auto s : people[i]) {\n                curr_skill |= (1 << skill_idx[s]);\n            }\n            for (auto &[key, val] : dp) {\n                int c = key | curr_skill;\n                if (dp.find(c) == dp.end() or dp[c].size() > 1  + dp[key].size()) {\n                    dp[c] = val;\n                    dp[c].push_back(i);\n                }\n            }\n        }\n        return dp[(1 << n) - 1];\n    }\n};\n```
['C++']