A project needs every skill in required. people[i] lists the skills of person i. A team covers a skill if at least one member has it.
Write smallestTeam(people, required) that returns the size of the smallest team covering every required skill, or -1 if no team can. If required is empty, the answer is 0.
Input: people = [["react","css"],["node"],["css","node","sql"]], required = ["react","node","sql"] Output: 2
Person 0 covers react and person 2 covers node and sql. No single person covers all three.
Input: people = [["go"],["rust"]], required = ["java"] Output: -1
Nobody knows java.
1 <= people.length <= 150 <= required.length <= 16, all distinctRun tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #675 Smallest Team Covering Skills. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.