Bitmask BFS
Intuition\nFirst let\'s look at constraints. Number of skills is limited by 16, so all possible combinations of skills for the worst case are limited by  2^{16}
# Intuition\nFirst let\'s look at constraints. Number of skills is limited by 16, so all possible combinations of skills for the worst case are limited by $$ 2^{16} $$ which is $$65536$$. We can consider every people\'s skills as bit mask, where $$1$$ at $$i^{th}$$ possition means worker has required_skill at position $$i$$. \nFor example:\n```\nreq_skills=["java", "c++", "python"], \npeople_skills = ["c++", "java"]\nbit_mask_binary = 110 \nbit mask_decimal = 6\n``` \n\n# Approach\nLet\'s assume that we are initially at position $$0$$, and our goal is to achieve position target $$ 2 ^ {len(reqskills)} - 1 $$. We will consider skills bit mask $$s$$ as transition from position $$pos$$ to position $$pos \\ OR\\ s$$ where $$or$$ is bitwise operator. \nWe need to iterate from position $$0$$ to $$target$$ and at each step try to apply each transition(people\'s skills bit mask) if it improves distance. For all distance improvemnents we have to memorize transitions.\nAs upgrade instead of iterating through all positions from $$0$$ to $$target$$, $$BFS$$ could be used.\n\nThen we only have to build the final result from our memorized transitions starting at $$target$$ and until we reach $$0$$.\n\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:$$O(2 ^{N}* M)$$ where $$N$$ - number of required skills and $$M$$ - number of people. \n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(2 ^ N)$$ where $$N$$ - number of required skills\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n\n# Code\n```\nconst val MAX = 1000000\n\nclass Solution {\n    fun smallestSufficientTeam(req_skills: Array<String>, people: List<List<String>>): IntArray {\n        val target = (1 shl (req_skills.size)) - 1\n        val peopleSkills = people.map { toNumber(it, req_skills) }\n        val from = Array<Pair<Int, Int>>(target + 1) { 0 to 0 }\n        val dist = IntArray(target + 1) { MAX }\n        dist[0] = 0\n        for (pos in 0 .. target) {\n            for ((i, s) in peopleSkills.withIndex()) {\n                if (dist[pos] + 1 < dist[pos or s]) {\n                    dist[pos or s] = dist[pos] + 1\n                    from[pos or s] = pos to i\n                }\n            }\n        }\n\n        val res = mutableListOf<Int>()\n        var v = target\n        while (v != 0) {\n            res.add(from[v].second)\n            v = from[v].first\n        }\n        return res.toIntArray()\n    }\n\n    fun toNumber(skills: List<String>, reqSkills: Array<String>): Int {\n        return skills.map { 1 shl (reqSkills.indexOf(it)) }.sum()\n    }\n}\n```
['Dynamic Programming', 'Bit Manipulation', 'Graph', 'Bitmask', 'Kotlin']