1452. People Whose List of Favorite Companies Is Not a Subset of Another List Medium

@problem@discussion
#Array#Hash Table#String



1/**
2 * [1452] People Whose List of Favorite Companies Is Not a Subset of Another List
3 *
4 * Given the array favoriteCompanies where favoriteCompanies[i] is the list of favorites companies for the ith person (indexed from 0).
5 * Return the indices of people whose list of favorite companies is not a subset of any other list of favorites companies. You must return the indices in increasing order.
6 *  
7 * Example 1:
8 * 
9 * Input: favoriteCompanies = [["leetcode","google","facebook"],["google","microsoft"],["google","facebook"],["google"],["amazon"]]
10 * Output: [0,1,4] 
11 * Explanation: 
12 * Person with index=2 has favoriteCompanies[2]=["google","facebook"] which is a subset of favoriteCompanies[0]=["leetcode","google","facebook"] corresponding to the person with index 0. 
13 * Person with index=3 has favoriteCompanies[3]=["google"] which is a subset of favoriteCompanies[0]=["leetcode","google","facebook"] and favoriteCompanies[1]=["google","microsoft"]. 
14 * Other lists of favorite companies are not a subset of another list, therefore, the answer is [0,1,4].
15 * 
16 * Example 2:
17 * 
18 * Input: favoriteCompanies = [["leetcode","google","facebook"],["leetcode","amazon"],["facebook","google"]]
19 * Output: [0,1] 
20 * Explanation: In this case favoriteCompanies[2]=["facebook","google"] is a subset of favoriteCompanies[0]=["leetcode","google","facebook"], therefore, the answer is [0,1].
21 * 
22 * Example 3:
23 * 
24 * Input: favoriteCompanies = [["leetcode"],["google"],["facebook"],["amazon"]]
25 * Output: [0,1,2,3]
26 * 
27 *  
28 * Constraints:
29 * 
30 * 	1 <= favoriteCompanies.length <= 100
31 * 	1 <= favoriteCompanies[i].length <= 500
32 * 	1 <= favoriteCompanies[i][j].length <= 20
33 * 	All strings in favoriteCompanies[i] are distinct.
34 * 	All lists of favorite companies are distinct, that is, If we sort alphabetically each list then favoriteCompanies[i] != favoriteCompanies[j].
35 * 	All strings consist of lowercase English letters only.
36 * 
37 */
38pub struct Solution {}
39
40// problem: https://leetcode.com/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/
41// discuss: https://leetcode.com/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/discuss/?currentPage=1&orderBy=most_votes&query=
42
43// submission codes start here
44
45impl Solution {
46    pub fn people_indexes(favorite_companies: Vec<Vec<String>>) -> Vec<i32> {
47        vec![]
48    }
49}
50
51// submission codes end
52
53#[cfg(test)]
54mod tests {
55    use super::*;
56
57    #[test]
58    fn test_1452() {
59    }
60}
61


Back
© 2025 bowen.ge All Rights Reserved.