small simple c++ dp code with explanation | using bitmasking
credits: https://leetcode.com/problems/smallest-sufficient-team/discuss/958406/DP-or-BITMASKS-or\n\nclass Solution {\npublic:\nvector<int> smallestSufficientTea
credits: https://leetcode.com/problems/smallest-sufficient-team/discuss/958406/DP-or-BITMASKS-or\n```\nclass Solution {\npublic:\nvector<int> smallestSufficientTeam(vector<string> &skills, vector<vector<string>> &people)\n{\n    int n=people.size();\n    int target=(1<<(int)skills.size())-1;\n    map<string,int> skillNo;\n    for(int i=0;i<skills.size();i++) skillNo[skills[i]]=i;\n    // store skills of the people in the form of bitmask\n    vector<int> peopleSkill(n,0);\n    for(int i=0;i<n;i++) for(auto it:people[i]) peopleSkill[i]|=(1<<skillNo[it]);\n\t//  dp[i]-> {min_no_of_workers_to_get_this_skills_configuration , indexes_of_workers};\n    vector<pair<int,vector<int>>> dp(target+1,{100,{-1}});\n    for(int i=0;i<peopleSkill.size();i++){\n        dp[peopleSkill[i]].first=1;\n        dp[peopleSkill[i]].second[0]=i;\n    }\n    for(int i=0;i<peopleSkill.size();i++){\n        for(int j=0;j<=target;j++){\n            //  try taking people[i]\n            if(dp[j|peopleSkill[i]].first>1+dp[j].first){\n                // include this person\n                dp[j|peopleSkill[i]].first=1+dp[j].first;\n                if(dp[j].second[0]==-1) dp[j|peopleSkill[i]].second={i};\n                else{\n                    dp[j|peopleSkill[i]].second=dp[j].second;\n                    dp[j|peopleSkill[i]].second.push_back(i);\n                }\n            }    \n            else{\n                // ignore this person\n            }\n        }\n    }\n    return dp[target].second;\n}\n};\n```
[]