1125. Smallest Sufficient Team Hard
1/**
2 * [1125] Smallest Sufficient Team
3 *
4 * In a project, you have a list of required skills req_skills, and a list of people. The i^th person people[i] contains a list of skills that the person has.
5 * Consider a sufficient team: a set of people such that for every required skill in req_skills, there is at least one person in the team who has that skill. We can represent these teams by the index of each person.
6 *
7 * For example, team = [0, 1, 3] represents the people with skills people[0], people[1], and people[3].
8 *
9 * Return any sufficient team of the smallest possible size, represented by the index of each person. You may return the answer in any order.
10 * It is guaranteed an answer exists.
11 *
12 * Example 1:
13 * Input: req_skills = ["java","nodejs","reactjs"], people = [["java"],["nodejs"],["nodejs","reactjs"]]
14 * Output: [0,2]
15 * Example 2:
16 * Input: req_skills = ["algorithms","math","java","reactjs","csharp","aws"], people = [["algorithms","math","java"],["algorithms","math","reactjs"],["java","csharp","aws"],["reactjs","csharp"],["csharp","math"],["aws","java"]]
17 * Output: [1,2]
18 *
19 * Constraints:
20 *
21 * 1 <= req_skills.length <= 16
22 * 1 <= req_skills[i].length <= 16
23 * req_skills[i] consists of lowercase English letters.
24 * All the strings of req_skills are unique.
25 * 1 <= people.length <= 60
26 * 0 <= people[i].length <= 16
27 * 1 <= people[i][j].length <= 16
28 * people[i][j] consists of lowercase English letters.
29 * All the strings of people[i] are unique.
30 * Every skill in people[i] is a skill in req_skills.
31 * It is guaranteed a sufficient team exists.
32 *
33 */
34pub struct Solution {}
35
36// problem: https://leetcode.com/problems/smallest-sufficient-team/
37// discuss: https://leetcode.com/problems/smallest-sufficient-team/discuss/?currentPage=1&orderBy=most_votes&query=
38
39// submission codes start here
40
41impl Solution {
42 pub fn smallest_sufficient_team(req_skills: Vec<String>, people: Vec<Vec<String>>) -> Vec<i32> {
43 vec![]
44 }
45}
46
47// submission codes end
48
49#[cfg(test)]
50mod tests {
51 use super::*;
52
53 #[test]
54 fn test_1125() {
55 }
56}
57
Back
© 2025 bowen.ge All Rights Reserved.