Skip to content
Programming101
Programming101

Learn everything about programming

  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programming101

Learn everything about programming

HackerRank Check Strict superset solution in python

YASH PAL, 31 July 2024

In this Check strict superset, 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.

HackerRank Check Strict superset solution in python

Problem solution in Python 2 programming.

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"

Problem solution in Python 3 programming.

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)

Problem solution in pypy programming.

# 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

Problem solution in pypy3 programming.

A = set(input().split())
N = int(input())
print(all(A > set(input().split())  for _ in range(N)))

coding problems python

Post navigation

Previous post
Next post
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
  • Hackerrank Day 6 Lets Review 30 days of code solution
  • Hackerrank Day 14 scope 30 days of code solution
©2025 Programming101 | WordPress Theme by SuperbThemes