Skip to content
Programming101
Programmingoneonone
  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programmingoneonone

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 solutions Python Solutions

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes