原题题目
代码实现(首刷自解 时空复杂度很高)
class Solution {
public:vector<int> smallestSufficientTeam(vector<string>& req_skills, vector<vector<string>>& people) {
int strl = req_skills.size(),num_people = people.size(),temp;vector<vector<int>> dp(1<<strl);vector<int>::iterator p;for(int i=0;i<1<<strl;i++){
if(dp[i].empty() && i)continue;for(int k=0;k<num_people;k++){
p = find(dp[i].begin(),dp[i].end(),k);if(p != dp[i].end()) continue;temp = i;for(string s1:people[k]){
for(int j=0;j<strl;j++){
if(req_skills[j] == s1){
temp |= (1<<j);if(dp[temp].empty() || dp[temp].size() > dp[i].size()+1){
dp[temp] = dp[i];dp[temp].push_back(k);}}}}}}return dp[(1<<strl)-1];}
};