Saturday, November 16, 2019

Check Strict Superset - Hacker Rank Solution

You are given a set  and  other sets.
Your job is to find whether set  is a strict superset of each of the  sets.

Print True, if  is a strict superset of each of the  sets. Otherwise, print False.
A strict superset has at least one element that does not exist in its subset.
Example
Set is a strict superset of set.
Set is not a strict superset of set.
Set is not a strict superset of set.
Input Format
The first line contains the space separated elements of set .
The second line contains integer , the number of other sets.
The next  lines contains the space separated elements of the other sets.
Constraints
Output Format
Print True if set  is a strict superset of all other  sets. Otherwise, print False.
Sample Input 0
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 0
False
Explanation 0
Set  is the strict superset of the set but not of the set because  is not in set .
Hence, the output is False.

Check Strict Superset - Hacker Rank Solution

set > otherSet


This tool tests whether the set is a proper(strict) superset of the other set like this: set >= otherSet and set != otherSet.

For Example:
print set([2, 9, 7, 1]) > set([1, 7]) #Output: True
print set([2, 9, 7, 1]) > set([1, 2, 7, 9]) #Output: False
A = set(raw_input().split());
print all(map(lambda x: (A > x), [set(raw_input().split()) for i in range(int(raw_input()))]))

No comments:

Post a Comment

Powered by Blogger.