Python short and clean. DP. Bitmask. Functional programming.
Approach\nTL;DR, Similar to Editorial solution Approach 2 but written functionally.\n\n# Complexity\n- Time complexity: O(2^k \cdot n \cdot log(n))\n (Note: log
# Approach\nTL;DR, Similar to [Editorial solution Approach 2](https://leetcode.com/problems/smallest-sufficient-team/editorial/) but written functionally.\n\n# Complexity\n- Time complexity: $$O(2^k \\cdot n \\cdot log(n))$$\n (Note: $$log(n)$$ is for `int.bit_count()`)\n\n- Space complexity: $$O(2^k)$$\n\nwhere,\n`n is number of people`,\n`k is number of req_skills`.\n\n# Code\n```python\nclass Solution:\n    def smallestSufficientTeam(self, req_skills: list[str], people: list[list[str]]) -> list[int]:\n        n, k = len(people), len(req_skills)\n\n        masks = lambda: accumulate(repeat(1), lshift)\n        skill_to_mask = dict(zip(req_skills, masks()))\n        person_skills_m = [reduce(or_, map(skill_to_mask.get, skills), 0) for skills in people]\n        \n        @cache\n        def smallest_team_m(req_skills_m: int) -> int:\n            rem_skills_m = map(lambda m: req_skills_m & ~m, person_skills_m)\n            filtered = (x for x in zip(masks(), rem_skills_m) if x[1] != req_skills_m)\n            teams = (p_m | smallest_team_m(rem_m) for p_m, rem_m in filtered)\n            return min(teams, key=int.bit_count) if req_skills_m else 0\n        \n        team_m = smallest_team_m((1 << k) - 1)\n        selector = map(int, bin(team_m)[:1:-1])\n        return list(compress(range(n), selector))\n\n\n```
['Dynamic Programming', 'Bit Manipulation', 'Bitmask', 'Python', 'Python3']