Check Subset

Sort by

recency

|

926 Discussions

|

  • + 0 comments

    T = int(input()) result = list([]) for i in range(T): n1 = int(input()) A = set(list(map(int, input().split()))[:n1]) n2 = int(input()) B = set(list(map(int, input().split()))[:n2])

    if A.issubset(B):
        result.append(True)
    else:
        result.append(False)
    

    for i in result: print(i)

  • + 0 comments

    can be done by checking on subset length:

    n = int(input())
    
    for i in range(0, n):
        n_a, a = int(input()), set(input().split())
        n_b, b = int(input()), set(input().split())
        subset = a - b
        print(len(subset) == 0)
    
  • + 0 comments
    from collections import Counter
    
    n = int(input())
    a = Counter(sorted(list(map(int, input().strip().split()))))
    b = [i for i,j in a.items() if j<n]
    print(*b)``
    
  • + 0 comments
    T = int(input())
    for _ in range(T):
        _ = int(input())
        A = set(map(int, input().split()))
        _ = int(input())
        B = set(map(int, input().split()))
        print(A.issubset(B))   
    
  • + 0 comments

    simple logic

    t = int(input()) i = 0 while i in range(t):
    set_a = int(input()) set_a_list = set(list(input().split())) set_b = int(input()) set_b_list = set(list(input().split())) print(set_a_list.issubset(set_b_list)) i += 1