java.lang.Object
g1401_1500.s1452_people_whose_list_of_favorite_companies_is_not_a_subset_of_another_list.Solution

public class Solution extends Object
1452 - People Whose List of Favorite Companies Is Not a Subset of Another List.<p>Medium</p> <p>Given the array <code>favoriteCompanies</code> where <code>favoriteCompanies[i]</code> is the list of favorites companies for the <code>ith</code> person ( <strong>indexed from 0</strong> ).</p> <p><em>Return the indices of people whose list of favorite companies is not a <strong>subset</strong> of any other list of favorites companies</em>. You must return the indices in increasing order.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> favoriteCompanies = [[&ldquo;leetcode&rdquo;,&ldquo;google&rdquo;,&ldquo;facebook&rdquo;],[&ldquo;google&rdquo;,&ldquo;microsoft&rdquo;],[&ldquo;google&rdquo;,&ldquo;facebook&rdquo;],[&ldquo;google&rdquo;],[&ldquo;amazon&rdquo;]]</p> <p><strong>Output:</strong> [0,1,4]</p> <p><strong>Explanation:</strong> Person with index=2 has favoriteCompanies[2]=[&ldquo;google&rdquo;,&ldquo;facebook&rdquo;] which is a subset of favoriteCompanies[0]=[&ldquo;leetcode&rdquo;,&ldquo;google&rdquo;,&ldquo;facebook&rdquo;] corresponding to the person with index 0. Person with index=3 has favoriteCompanies[3]=[&ldquo;google&rdquo;] which is a subset of favoriteCompanies[0]=[&ldquo;leetcode&rdquo;,&ldquo;google&rdquo;,&ldquo;facebook&rdquo;] and favoriteCompanies[1]=[&ldquo;google&rdquo;,&ldquo;microsoft&rdquo;]. Other lists of favorite companies are not a subset of another list, therefore, the answer is [0,1,4].</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> favoriteCompanies = [[&ldquo;leetcode&rdquo;,&ldquo;google&rdquo;,&ldquo;facebook&rdquo;],[&ldquo;leetcode&rdquo;,&ldquo;amazon&rdquo;],[&ldquo;facebook&rdquo;,&ldquo;google&rdquo;]]</p> <p><strong>Output:</strong> [0,1]</p> <p><strong>Explanation:</strong> In this case favoriteCompanies[2]=[&ldquo;facebook&rdquo;,&ldquo;google&rdquo;] is a subset of favoriteCompanies[0]=[&ldquo;leetcode&rdquo;,&ldquo;google&rdquo;,&ldquo;facebook&rdquo;], therefore, the answer is [0,1].</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> favoriteCompanies = [[&ldquo;leetcode&rdquo;],[&ldquo;google&rdquo;],[&ldquo;facebook&rdquo;],[&ldquo;amazon&rdquo;]]</p> <p><strong>Output:</strong> [0,1,2,3]</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= favoriteCompanies.length <= 100</code></li> <li><code>1 <= favoriteCompanies[i].length <= 500</code></li> <li><code>1 <= favoriteCompanies[i][j].length <= 20</code></li> <li>All strings in <code>favoriteCompanies[i]</code> are <strong>distinct</strong>.</li> <li>All lists of favorite companies are <strong>distinct</strong> , that is, If we sort alphabetically each list then <code>favoriteCompanies[i] != favoriteCompanies[j].</code></li> <li>All strings consist of lowercase English letters only.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details