Check Strict Superset in python

Check Strict Superset in python

Instructor-svgAl-Mamun Sarkar
Mar 24 , 2020

Checking Strict Superset. The following code shows how to check strict superset on set in python. This is the solution of the HackerRank Check Strict Superset Python Sets problem.

Code:


def strict_superset(A):
	n = int( input() )
	for x in range(0, n):
		sub_set = set(input().split())
		if len(sub_set.difference(A)):
			return False

	return True


if __name__ == '__main__':
	A = set(input().split())
	if strict_superset(A):
		print('True')
	else:
		print('False')

 

Test 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

Test Output:

False
  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram