1
# Runtime: 2036 ms (Top 22.82%) | Memory: 203 MB (Top 6.04%)2
from collections import defaultdict3
from functools import lru_cache7
def smallestSufficientTeam(8
self, req_skills: List[str], people: List[List[str]]11
skills = {skill: i for i, skill in enumerate(req_skills)}12
people_mask = defaultdict(int)13
for i, cur_skills in enumerate(people):15
for skill in cur_skills:16
mask |= 1 << skills[skill]19
self.res = float("inf")24
# l: length of current self.path25
# mask: mask for current skills27
if mask == (1 << N) - 1:30
self.respath = self.path[:]38
if mask & people_mask[i] != people_mask[i]:39
dfs(i + 1, l + 1, mask | people_mask[i])