Skip to content

Instantly share code, notes, and snippets.

@aljorhythm
Created May 17, 2020 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aljorhythm/9901712c315b7c84a0e972e6a14d5693 to your computer and use it in GitHub Desktop.
Save aljorhythm/9901712c315b7c84a0e972e6a14d5693 to your computer and use it in GitHub Desktop.
class Solution(object):
def peopleIndexes(self, favoriteCompanies):
indices = []
favoriteCompanies = map(set, favoriteCompanies)
for i, person in enumerate(favoriteCompanies):
has_subset = False
for j, otherPerson in enumerate(favoriteCompanies):
if i == j:
continue
is_subset = True
for c in person:
if c not in otherPerson:
is_subset = False
break
if is_subset:
has_subset = True
break
if not has_subset:
indices.append(i)
return indices
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment