package leetcode;

import java.util.Arrays;
import java.util.List;

/**
 * https://leetcode.com/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/
 */
public class Problem1452 {
    public List<Integer> peopleIndexes(List<List<String>> favoriteCompanies) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1452 prob = new Problem1452();
        System.out.println(prob.peopleIndexes(Arrays.asList(
            Arrays.asList("leetcode","google","facebook"),
            Arrays.asList("google","microsoft"),
            Arrays.asList("google","facebook"),
            Arrays.asList("google"),
            Arrays.asList("amazon")
        ))); // [0,1,4]
        System.out.println(prob.peopleIndexes(Arrays.asList(
            Arrays.asList("leetcode","google","facebook"),
            Arrays.asList("google","microsoft"),
            Arrays.asList("google","facebook"),
            Arrays.asList("google"),
            Arrays.asList("amazon"),
            Arrays.asList("leetcode", "facebook")
        ))); // [0,1,4]
        System.out.println(prob.peopleIndexes(Arrays.asList(
            Arrays.asList("leetcode","google","facebook"),
            Arrays.asList("leetcode","amazon"),
            Arrays.asList("facebook","google")
        ))); // [0,1]
        System.out.println(prob.peopleIndexes(Arrays.asList(
            Arrays.asList("leetcode"),
            Arrays.asList("google"),
            Arrays.asList("facebook"),
            Arrays.asList("amazon")
        ))); // [0,1,2,3]
    }
}

@@ -34,17 +34,46 @@
 il.Array
-s
+List;%0Aimport java.util.HashSet
 ;%0Aimport
@@ -88,16 +88,38 @@
 il.List;
+%0Aimport java.util.Set;
 %0A%0A/**%0A *
@@ -344,388 +344,292 @@
     
-// TODO%0A        return null;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1452 prob = new Problem1452();%0A        System.out.println(prob.peopleIndexes(Arrays.asList(%0A            Arrays.asList(%22leetcode%22,%22google%22,%22facebook%22),%0A            Arrays.asList(%22google%22,%22microsoft%22),%0A            Arrays.asList(%22google%22,%22facebook%22),%0A            Arrays.asList(%22google%22),
+Set%3CString%3E%5B%5D companies = new Set%5BfavoriteCompanies.size()%5D;%0A        for (int i = 0; i %3C favoriteCompanies.size(); i++) %7B%0A            companies%5Bi%5D = new HashSet%3C%3E();%0A            for (String company : favoriteCompanies.get(i)) %7B%0A                companies%5Bi%5D.add(company);%0A            %7D
 %0A   
@@ -637,899 +637,533 @@
     
+%7D%0A
     
-Arrays.asList(%22amazon%22)%0A        ))); // %5B0,1,4%5D%0A        System.out.println(prob.peopleIndexes(Arrays.asList(%0A            Arrays.asList(%22leetcode%22,%22google%22,%22facebook%22),%0A            Arrays.asList(%22google%22,%22microsoft%22),%0A            Arrays.asList(%22google%22,%22facebook%22),%0A            Arrays.asList(%22google%22),%0A            Arrays.asList(%22amazon%22),%0A            Arrays.asList(%22leetcode%22, %22facebook%22)%0A
+    List%3CInteger%3E answer = new ArrayList%3C%3E();%0A        for (int i = 0; i %3C favoriteCompanies.size(); i++) %7B%0A            boolean subset = false;%0A            for (int j = 0; j %3C favoriteCompanies.size(); j++) %7B%0A                if (i == j) %7B%0A                    continue;%0A             
    
+%7D%0A
      
-))); // %5B0,1,4%5D%0A        System.out.println(prob.peopleIndexes(Arrays.asList(%0A            Arrays.asList(%22leetcode%22,%22google%22,%22facebook%22),%0A            Arrays.asList(%22leetcode%22,%22amazon%22),%0A            Arrays.asList(%22facebook%22,%22google%22)%0A
+           if (companies%5Bj%5D.containsAll(companies%5Bi%5D)) %7B%0A                    subset = true;%0A            
     
+%7D%0A
     
-))); // %5B0,1%5D%0A        System.out.println(prob.peopleIndexes(Arrays.asList(%0A            Arrays.asList(%22leetcode%22),%0A            Arrays.asList(%22google%22),%0A            Arrays.asList(%22facebook%22),%0A            Arrays.asList(%22amazon%22)%0A        ))); // %5B0,1,2,3%5D
+        %7D%0A            if (!subset) %7B%0A                answer.add(i);%0A            %7D%0A        %7D%0A        return answer;
 %0A   

Solve problem 1452