C++ faster dfs on skill not people, clean simple concise code
use standard dfs, but on req_skills, not people.\n\n\nclass Solution {\npublic:\n    vector<int> smallestSufficientTeam(vector<string>& req_skills, vector<vecto
use standard dfs, but on req_skills, not people.\n\n```\nclass Solution {\npublic:\n    vector<int> smallestSufficientTeam(vector<string>& req_skills, vector<vector<string>>& people) {\n\t\t// get id of the req_skills\n        unordered_map<string, int> id;\n        for (int i = 0; i < req_skills.size(); i++) {\n            id[req_skills[i]] = i;\n        }\n        \n\t\t// hash[skill_id] = {people_id with this skill}\n        vector<vector<int>> hash(req_skills.size());\n        \n        // add people skill to hash\n        for (int i = 0; i < people.size(); i++) {\n            for (string &s : people[i]) {\n\t\t\t\t// if this skill is not required, just skip\n                if (id.find(s) == id.end()) {\n                    continue;\n                }\n                int index = id[s];\n                hash[index].push_back(i);\n            }\n        }\n        \n        // dfs\n\t\t// path is current choice of people\n        unordered_set<int> path;\n\t\t// ans is the current optimal choice of people\n\t\t// initialize to use all the people\n        unordered_set<int> ans;\n        for (int i = 0; i < people.size(); i++) {\n            ans.insert(i);\n        }\n        dfs(hash, 0, path, ans);\n        \n        return vector<int>(ans.begin(), ans.end());\n    }\nprivate:\n    void dfs(vector<vector<int>> &hash, int index, unordered_set<int> &path, unordered_set<int> &ans) {\n        // find a solution, compare with current optimal\n        if (index == hash.size()) {\n            if (path.size() < ans.size()) {\n                ans = path;\n            }\n            return;\n        }\n        \n        // prune, early stop\n        if (path.size() >= ans.size()) {\n            return;\n        }\n        \n        // dfs + backtracking\n        for (int &i : hash[index]) {\n            // choose people i for skill_id = index\n            bool exist = (path.find(i) != path.end());\n            path.insert(i);\n            dfs(hash, index + 1, path, ans);\n\t\t\t// if this people does not exist in the choice before, than need to backtrack (delete)\n            if (!exist) {\n                path.erase(i);\n            }\n        }\n    }\n};\n```
[]