dp
where dp[mask]
represents the smallest team that can cover the skills represented by mask
.dp[0]
to 0, representing an empty team for no skills.skillsMask
from 1 to 2^m - 1
, iterate over all people.smallerSkillsMask
by removing the person's skills from skillsMask
.dp[skillsMask]
with the smaller of the current value or the union of dp[smallerSkillsMask]
and the current person.dp[2^m - 1]
.