Check Strict Superset

  • + 0 comments

    Here's my solution that does not require an additional data structure to track the results of each comparison. This may be preferable when you do not want the additional memory overhead as well as the additional loop over the results. This also ends the main loop faster as it can exit as soon as any False is found.

    s = set(map(int,input().split()))
    n = int(input())
    allsupersets = True
    for _ in range(n):
    
        s1 = set(map(int,input().split()))
        if not s.issuperset(s1):
            allsupersets = False
            break
    print(allsupersets)