Smallest Sufficient Team
Problem statement
Given a list of distinct required skills and the skills held by each person, return indices of a smallest team whose combined skills cover every required skill.
If several minimum-size teams exist, return the lexicographically smallest increasing index list. Every input has at least one sufficient team.
Function
smallestSufficientTeam(requiredSkills: String[], peopleSkills: List<List<String>>) → int[]Examples
Example 1
requiredSkills = ["java","sql","aws"]peopleSkills = [["java"],["sql"],["aws"],["java","sql"]]return = [2,3]No one has all three skills, so a team needs at least two people. Persons 2 and 3 cover java, sql and aws together; every other pair misses a skill.
Example 2
requiredSkills = ["a"]peopleSkills = [["a"]]return = [0]The only person has the only skill, so the team is [0].
Example 3
requiredSkills = ["a","b"]peopleSkills = [["a"],["b"],["a","b"]]return = [2]Person 2 alone has both skills, so one person is enough. Persons 0 and 1 also cover both, but that team is larger.
Constraints
1 <= requiredSkills.length <= 16.1 <= peopleSkills.length <= 60.- Skill names are case-sensitive; unrequired skills may be ignored.