FunctionRacerProblemsRace

Smallest Team With Every Skill

HardBitsPython, JavaScript, TypeScript, Java, C++

skills lists the different skills a job needs, and people[i] lists the skills person i has, all of them taken from skills. Every needed skill is held by at least one person.

Return the size of the smallest team whose members together have every skill in skills.

Example 1

skills ["cook","drive","sing"]
people [["cook"],["drive","sing"],["cook","sing"],["drive"]]
returns 2

Person 0 cooks, and person 1 drives and sings. Nobody has all three skills alone.

Example 2

skills ["row"]
people [["row"],["row"]]
returns 1

Either person is enough.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Bits problems