Given the array favoriteCompanies where favoriteCompanies[i] is the list of favorites companies for the ith person (indexed from 0).

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.

&nbsp;
Example 1:

Input: favoriteCompanies = [["leetcode","google","facebook"],["google","microsoft"],["google","facebook"],["google"],["amazon"]]
Output: [0,1,4] 
Explanation: 
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. 
Person with index=3 has favoriteCompanies[3]=["google"] which is a subset of favoriteCompanies[0]=["leetcode","google","facebook"] and favoriteCompanies[1]=["google","microsoft"]. 
Other lists of favorite companies are not a subset of another list, therefore, the answer is [0,1,4].


Example 2:

Input: favoriteCompanies = [["leetcode","google","facebook"],["leetcode","amazon"],["facebook","google"]]
Output: [0,1] 
Explanation: In this case favoriteCompanies[2]=["facebook","google"] is a subset of favoriteCompanies[0]=["leetcode","google","facebook"], therefore, the answer is [0,1].


Example 3:

Input: favoriteCompanies = [["leetcode"],["google"],["facebook"],["amazon"]]
Output: [0,1,2,3]


&nbsp;
Constraints:


	1 &lt;= favoriteCompanies.length &lt;= 100
	1 &lt;= favoriteCompanies[i].length &lt;= 500
	1 &lt;= favoriteCompanies[i][j].length &lt;= 20
	All strings in favoriteCompanies[i] are distinct.
	All lists of favorite companies are distinct, that is, If we sort alphabetically each list then favoriteCompanies[i] != favoriteCompanies[j].
	All strings consist of lowercase English letters only.


class Solution:
    def peopleIndexes(self, favoriteCompanies: List[List[str]]) -> List[int]:
        
        F = favoriteCompanies
        ans = [] 
        
        seen = set() 
        
        for i in range(len(F)):
            for j in range(i+1,len(F)):
                st1 = set(F[i])
                st2 = set(F[j])
                if st1.intersection(st2) == st1: seen.add(i)
                if st2.intersection(st1) == st2: seen.add(j) 

        ans = []
        for i in range(len(F)):
            if i in seen: continue 
            ans.append(i) 
            
        return ans
class Solution {
    public List<Integer> peopleIndexes(List<List<String>> favoriteCompanies) {
        Set<String>[] fav = new Set[favoriteCompanies.size()];
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < favoriteCompanies.size(); i++) {
            set.add(i);
            fav[i] = new HashSet<>(favoriteCompanies.get(i));
        }
        for (int i = 1; i < favoriteCompanies.size(); i++) {
            if (!set.contains(i)) continue;
            for (int j = 0; j < i; j++) {
                if (!set.contains(j)) continue;
                if (isSubSet(fav[j], fav[i])) set.remove(j);
                if (isSubSet(fav[i], fav[j])) set.remove(i);
            }
        }
        List<Integer> ans = new ArrayList<>(set);
        Collections.sort(ans);
        return ans;
    }

    private boolean isSubSet(Set<String> child, Set<String> parent) {
        if (child.size() > parent.size()) return false;
        return parent.containsAll(child);
    }
}
/*
 * author: deytulsi18
 * problem: https://leetcode.com/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/
 * time complexity: O(n*n*m)
 * auxiliary space: O(1)
 * language: cpp
 */
class Solution {
public:
    bool isSubset(vector<string> &b, vector<string> &a)
    {
       return (includes(a.begin(), a.end(),
                  b.begin(), b.end()));
    }
    vector<int> peopleIndexes(vector<vector<string>>& favoriteCompanies) {

        int n = favoriteCompanies.size();
        vector<int> res;

        for (auto &i : favoriteCompanies)
        sort(begin(i), end(i));

        for (int i = 0; i < n; i++)
        {
            bool isValid = true;

            for (int j = 0; j < n; j++)
                if (i != j)
                    if (isSubset(favoriteCompanies[i], favoriteCompanies[j]))
                    {
                        isValid = false;
                        break;
                    }

            if (isValid)
                res.emplace_back(i);
        }

        return res;
    }
};;
var peopleIndexes = function(favoriteCompanies) {
    let arr = favoriteCompanies
    let len = arr.length
    let ret = []
    for(let i = 0; i < len; i++) {
        let item1 = arr[i]
        let isSubset = false
        for(let j = 0; j < len; j++) {
            if(i === j) continue
            let item2 = arr[j]
            let s = new Set(item2)
            if(item1.every(a => s.has(a))) {
                isSubset = true
                break
            }
        }
        if(!isSubset) ret.push(i)
    }
    return ret
};
People Whose List of Favorite Companies Is Not a Subset of Another List