Ctrl K

Wishlists Nobody Covers

Medium
Each survey participant named the cities they would like to visit: wishlists[i] is the list of participant i (0-based). A list is covered if every one of its cities also appears in some other participant's list. Return, in increasing order, the indices of participants whose lists are not covered by anyone else's.
Example 1
wishlists=[["rome", "paris", "oslo"], ["paris", "oslo"], ["lima"], ["oslo", "lima"]] → [0, 3]

List 1 is entirely inside list 0, and list 2 is inside list 3. That leaves 0 and 3.

Example 2
wishlists=[["tokyo"], ["seoul"], ["tokyo", "seoul", "hanoi"]] → [2]

Both short lists are covered by the third one.

Example 3
wishlists=[["cairo", "dubai"], ["dubai", "doha"]] → [0, 1]
Constraints
  • 1 ≤ len(wishlists) ≤ 100
  • 1 ≤ len(wishlists[i]) ≤ 500
  • 1 ≤ name length ≤ 20, lowercase English letters only
  • No city repeats within a single list
  • No two lists are equal as sets
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsAnagram Buckets MediumSplit Into Dictionary Words MediumWords Equal Up to a Shift MediumA Subsequence of One Word Only MediumFiles With the Same Content Medium
loading Python…
Input
wishlists=[["rome", "paris", "oslo"], ["paris", "oslo"], ["lima"], ["oslo", "lima"]]
Expected
[0, 3]

Run checks the first 3 tests in your browser. Submit checks all 70 tests on the server, hidden ones included.