Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
You are given two sets, A and B.
Your job is to find whether set A is a subset of set B.
If set A is subset of set B, print True.
If set A is not a subset of set B, print False.
The first line will contain the number of test cases, T.
The first line of each test case contains the number of elements in set A.
The second line of each test case contains the space separated elements of set A.
The third line of each test case contains the number of elements in set B.
The fourth line of each test case contains the space separated elements of set B.
Output True or False for each test case on separate lines.
3
5
1 2 3 5 6
9
9 8 5 6 3 2 1 4 7
1
2
5
3 6 5 4 1
7
1 2 3 5 6 8 9
3
9 8 2
True
False
False
Test Case 01 Explanation
Set A = {1 2 3 5 6}
Set B = {9 8 5 6 3 2 1 4 7}
All the elements of set A are elements of set B.
Hence, set A is a subset of set B.
for i in range(int(raw_input())): #More than 4 lines will result in 0 score. Do not leave a blank line also.
a = int(raw_input()); A = set(raw_input().split())
b = int(raw_input()); B = set(raw_input().split())
print "True" if A.issubset(B) else "False"
# Enter your code here. Read input from STDIN. Print output to STDOUT
for _ in range(int(input())):
x, a, z, b = input(), set(input().split()), input(), set(input().split())
print(a.issubset(b))
# Enter your code here. Read input from STDIN. Print output to STDOUT
for case in range(int(raw_input())):
element_count1, set1 = int(raw_input()), set(raw_input().split())
element_count2, set2 = int(raw_input()), set(raw_input().split())
print(len(set1.difference(set2))==0)
# Enter your code here. Read input from STDIN. Print output to STDOUT
for i in range(int(input())):
a = int(input()); A = set(input().split())
b = int(input()); B = set(input().split())
if(len(A.difference(B))==0):
print("True")
else:
print("False")
In our experience, we suggest you solve this Check Subset Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
Check Subset is available on Hacker Rank for Free, if you are stuck anywhere between compilation, just visit Queslers to get all Hacker Rank Solution
I hope this Check Subset 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