Trains the technique from
LeetCode 1125Smallest Sufficient TeamThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A shutdown job may only go ahead once every certificate in needed is held by somebody on the crew. crew[i] lists the certificates that candidate i holds. A group of candidates is cleared for the job when, for every certificate in needed, at least one candidate in the group holds it. One candidate may hold several certificates, and a candidate may hold none at all.
Return the indices of the candidates in a cleared group of the smallest possible size, listed in increasing order.
Two different groups may both be smallest, so exactly one answer is asked for: among the cleared groups of the smallest size, return the one whose list of indices is smaller when the two lists are read side by side from the front, that is, the one with the smaller index at the first place where the lists differ.
Example 1
Candidate 2 holds weld, rig and hoist, which is every certificate the job needs, so the group holding just that one candidate is cleared.
Example 2
Candidates 0 and 1 between them hold weld, rig, hoist and crane, so that pair is cleared. Candidates 1 and 2 are also a cleared pair, and the tie-break reads the two lists side by side: 0 is smaller than 1 at the first place they differ.
Example 3
Candidate 0 holds no certificates. Candidate 1 holds weld and candidate 2 holds rig, so that pair covers both needed certificates.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def smallest_crew(needed: list[str], crew: list[list[str]]) -> list[int]:public int[] smallestCrew(String[] needed, List<List<String>> crew)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.