skills (all names are distinct). There are some candidates: candidates[i] is the list of skills of candidate i.
A team works if every skill in skills is held by at least one of its members. Find a working team with as few people as possible and return the indices of its members (0-based) in any order.
The input guarantees that a working team exists and that the smallest one is unique.skills=['sql', 'python', 'excel'], candidates=[['sql'], ['python', 'excel'], ['excel']] → [1, 0]
Candidate 0 knows sql, candidate 1 knows python and excel: together they cover all three skills. Nobody has all three alone.
skills=['go', 'k8s', 'aws', 'figma'], candidates=[['go', 'k8s'], ['aws'], ['figma'], ['k8s', 'aws', 'figma']] → [3, 0]
Candidate 3 covers k8s, aws and figma, and only candidate 0 knows go. The two of them are enough, and no single person has everything.
skills=['ml'], candidates=[[], ['ml']] → [1]
Candidate 0 has none of the needed skills; candidate 1 alone is enough.
skills are distinctskillsskills=['sql', 'python', 'excel'], candidates=[['sql'], ['python', 'excel'], ['excel']]
[1, 0]
Run checks the first 3 tests in your browser. Submit checks all 40 tests on the server, hidden ones included.