People Whose List of Favorite Companies Is Not a Subset of Another List

Given the array favoriteCompanies, where favoriteCompanies[i] is the list of favorite 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 favorite companies. You must return the indices in increasing order.

Example 1
InputfavoriteCompanies = [["leetcode","google","facebook"],["google","microsoft"],["google","facebook"],["google"],["amazon"]]
Output[0,1,4]
People with indices 2 and 3 have lists that are subsets of other people's lists, while the lists at indices 0, 1, and 4 are not subsets of any other list.
Example 2
InputfavoriteCompanies = [["leetcode","google","facebook"],["leetcode","amazon"],["facebook","google"]]
Output[0,1]
favoriteCompanies[2] is a subset of favoriteCompanies[0], so only indices 0 and 1 remain.

Constraints

  • 1 <= favoriteCompanies.length <= 100
  • 1 <= favoriteCompanies[i].length <= 500
  • 1 <= favoriteCompanies[i][j].length <= 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.

Asked at 2 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate