Check Strict Superset Hacker Rank Solution – Queslers

Problem: Check Strict Superset Hacker Rank Solution

You are given a set A and n other sets.
Your job is to find whether set A is a strict superset of each of the N sets.
Print True, if A is a strict superset of each of the N sets. Otherwise, print False.
A strict superset has at least one element that does not exist in its subset.
Example
Set ([1, 3, 4]) is a strict superset of set ([1, 3]).
Set ([1, 3, 4]) is not a strict superset of set ([1, 3, 4]).
Set ([1, 3, 4]) is not a strict superset of set ([1, 3, 5]).


Input Format :

The first line contains the space separated elements of set A.
The second line contains integer n, the number of other sets.
The next n lines contains the space separated elements of the other sets.

Constraints :

  • 0 < len(set(A)) < 501
  • 0 < N < 21
  • 0 < len(other set) < 101

Output Format :

Print True if set A is a strict superset of all other N sets. Otherwise, print False.


Sample Input :

1 2 3 4 5 6 7 8 9 10 11 12 23 45 84 78
2
1 2 3 4 5
100 11 12

Sample Output :

False

Explanation :

Set A is the strict superset of the set ([1, 2, 3, 4, 5]) but not of the set ([100, 11, 12]) because 100 is not in set A. Hence, the output is False.

Check Strict Superset Hacker Rank Solution in python 2

S=set([int(x) for x in raw_input().split()])
n=int(raw_input());stop=0
while n>0 and stop==0:
    n-=1
    B=set([int(x) for x in raw_input().split()])
    if not(S.issuperset(B) and len(S-B)>0): stop=1
if stop==1: print "False"
else: print "True"

Check Strict Superset Hacker Rank Solution in python 3

def isstrictsuperset(a,b):
    # true if a is a strict superset of b
    return b.issubset(a) and not(a.issubset(b))

a = set(int(x) for x in input().split(' '))
n = int(input())
res = True

for _ in range(n):
    b = set(int(x) for x in input().split(' '))
    res &= isstrictsuperset(a,b)
    
print(res)

Check Strict Superset Hacker Rank Solution in pypy

# Enter your code here. Read input from STDIN. Print output to STDOUT
A = set(raw_input().split())
is_strict_superset = True
for i in range(int(raw_input())): 
    B = set(raw_input().split())
    is_strict_superset = is_strict_superset and (A.intersection(B) == B and len(A) > len(B))
    
print is_strict_superset

Check Strict Superset Hacker Rank Solution in pypy 3

A = set(input().split())
N = int(input())
print(all(A > set(input().split())  for _ in range(N)))
Check Strict Superset Hacker Rank Solution Review:

In our experience, we suggest you solve this Check Strict Superset Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

Check Strict Superset is available on Hacker Rank for Free, if you are stuck anywhere between compilation, just visit Queslers to get all Hacker Rank Solution

Check Strict Superset Hacker Rank Solution Conclusion:

I hope this Check Strict Superset Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Hacker Rank Problem & Solutions >>

Mini-Max Sum Hacker Rank Solution

String Validators Hacker Rank Solution

Text Alignment Hacker Rank solution

String validators Hacker Rank Solution

Staircase Hacker Rank Solution

Leave a Reply

Your email address will not be published.