Take or NotTake | Memoization | Fully explained like simple DP problems
\n\n# Approach\n if(dp[i][mask]!=-1) \n      {\n          if(dp[i][mask] <= ans.size()) return;\n      }\n\n      \nit means if somehow at index i we have mask 
\n\n# Approach\n if(dp[i][mask]!=-1) \n      {\n          if(dp[i][mask] <= ans.size()) return;\n      }\n\n      \nit means if somehow at index i we have mask then prev answer is already stored but now when we again meet same condition and ans is long then prev so why we do it again\n\ndp[i][mask] = ans.size();\n\nwe store ans.size() only to dp no matter we meet our 111... condition\nand if we meet again this dp we check size as described above if it is bigger then we return because if we somehow meet the conditon it is bigger than our prev \n\n\n\n\n# Code\n```\nclass Solution {\npublic:\n\n   vector<int>temp;\n\n   void func(int i,vector<string>& req_skills, vector<int>pep_skill,int mask,vector<int>&ans,int n,vector<vector<int>> &dp)\n   {\n      if(i==pep_skill.size())\n      {\n          if(mask == (1<<n)-1) // all bits are 1\n          {\n            if(temp.size()==0 || temp.size()>ans.size()) // prev store array is bigger \n            {\n               temp=ans;\n            }\n          }\n          return ;\n      }\n      if(dp[i][mask]!=-1) \n      {\n          if(dp[i][mask] <= ans.size()) return;\n      }\n\n\n\n\n      func(i+1,req_skills,pep_skill,mask,ans,n,dp);  // notTake condition\n \n      ans.push_back(i);\n      func(i+1,req_skills,pep_skill,(mask | pep_skill[i]),ans,n,dp); // take condition\n      ans.pop_back();\n\n      dp[i][mask] = ans.size();\n\n   }\n    vector<int> smallestSufficientTeam(vector<string>& req_skills, vector<vector<string>>& people) {\n       \n       int n=req_skills.size();\n       int m=people.size();\n\n       vector<int>pep_skill;\n\n       for(int i=0;i<m;i++)\n       {\n           int skill=0;\n           for(int j=0;j<people[i].size();j++)\n           {\n               for(int k=0;k<n;k++)\n               {\n                  if(people[i][j]==req_skills[k])\n                  {\n                      skill=skill | (1<<k);  // setting the mask for each people skills\n                  }\n               }\n           }\n           pep_skill.push_back(skill);\n\n       }\n        vector<int>ans;\n\n        int target=pow(2,n); \n\n        vector<vector<int>> dp(m, vector<int>(target, -1));  // [index][target]  because 00 can to to max to 11 or 2^n \n\n        func(0,req_skills,pep_skill,0,ans,n,dp);\n        return temp;\n\n    }\n\n};\n```
['Dynamic Programming', 'C++']