BitMask HashMap Memoization
\n\n# Code\n\nclass Solution {\n    public int[] smallestSufficientTeam(String[] req_skills, List<List<String>> people) {\n        Map<String, Integer> skillInd
\n\n# Code\n```\nclass Solution {\n    public int[] smallestSufficientTeam(String[] req_skills, List<List<String>> people) {\n        Map<String, Integer> skillIndexMap = new HashMap<>();\n\n        for (int i = 0; i < req_skills.length; i++) {\n            skillIndexMap.put(req_skills[i], i);\n        }\n        int[] peopleSkillBitMask = new int[people.size()];\n\n        for (int i = 0; i < people.size(); i++) {\n            List<String> personSkill = people.get(i);\n            int mask = 0;\n\n            for (String skill : personSkill){\n                mask |= 1 << skillIndexMap.get(skill); //setting bit at that index indicating skills that person has\n            }\n            peopleSkillBitMask[i] = mask;\n        }\n        int endState = (1 << req_skills.length) - 1; //setting all bits indicating all skills\n        Map<String, Long> memo = new HashMap<>();\n        long state = recur(peopleSkillBitMask, endState ,0, 0, memo);\n        List<Integer> holder = new ArrayList<>();\n        int index = 0;\n        System.out.println(Long.toBinaryString(state));\n\n        while (state > 0) {\n            long ans = state & 1;\n\n            if (ans == 1) {\n                holder.add(index);\n            }\n            index++;\n            state >>= 1;\n        } \n        int[] ans = new int[holder.size()];\n\n        for (int i = 0; i < holder.size(); i++) {\n            ans[i] = holder.get(i);\n        }\n        return ans;\n    }\n\n    private long recur(int[] peopleSkillBitMask, int endState, int index, int mask, Map<String, Long> memo) {\n        \n        if (mask == endState) {\n            return 0;\n        }\n\n        if (index == peopleSkillBitMask.length) {\n            return Integer.MAX_VALUE;\n        }\n        String key = index + "|" + mask;\n\n        if (memo.containsKey(key)) {\n            return memo.get(key);\n        }\n        long ans = 0;\n        //Setting the bit to signify including of skills\n        long include = recur(peopleSkillBitMask, endState, index + 1, mask | peopleSkillBitMask[index], memo);\n        long exclude = recur(peopleSkillBitMask, endState, index + 1, mask, memo);\n        // Setting the bit as indicator that it has been included or excluded\n        // Using Long as 1 <= people.length <= 60\n        if (Long.bitCount(include) < Long.bitCount(exclude)) {\n            ans =  include | (1L << index);\n        } else {\n            ans = exclude;\n        }\n        memo.put(key, ans);\n        return ans;\n    }\n\n}\n```
['Hash Table', 'Bit Manipulation', 'Memoization', 'Bitmask', 'Java']