Skip to content

Commit 21330ae

Browse files
complete sets in python
1 parent 57e9b45 commit 21330ae

File tree

9 files changed

+62
-0
lines changed

9 files changed

+62
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
A = set(map(int, input().split()))
2+
r = True
3+
for _ in range(int(input())):
4+
B = set(map(int, input().split()))
5+
if A.issuperset(B) == False:
6+
r = False
7+
8+
print(r)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
for _ in range(int(input())):
2+
_, A = input(), set(map(int, input().split()))
3+
_, B = input(), set(map(int, input().split()))
4+
print(A.issubset(B))
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
e = int(input())
2+
E = set(map(int, input().split()))
3+
f = int(input())
4+
F = set(map(int, input().split()))
5+
S = E.difference(F)
6+
print(len(S))
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
e = int(input())
2+
E = set(map(int, input().split()))
3+
f = int(input())
4+
F = set(map(int, input().split()))
5+
S = E.intersection(F)
6+
print(len(S))
7+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
_ , A = int(input()), set(map(int, input().split()))
2+
q = int(input())
3+
for _ in range(q):
4+
command, B = input().split()[0], set(map(int, input().split()))
5+
getattr(A, command)(B)
6+
7+
print(sum(A))
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
e = int(input())
2+
E = set(map(int, input().split()))
3+
f = int(input())
4+
F = set(map(int, input().split()))
5+
S = E.symmetric_difference(F)
6+
print(len(S))
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
e = int(input())
2+
E = set(map(int, input().split()))
3+
f = int(input())
4+
F = set(map(int, input().split()))
5+
S = E.union(F)
6+
print(len(S))
7+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from collections import Counter
2+
_, l = input(), list(map(int, input().split()))
3+
rooms = set(l)
4+
5+
c = Counter(l)
6+
for r in rooms:
7+
if c[r] == 1:
8+
print(r)
9+
break

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ Solutions to some problems on Hackerrank.
139139
| Sets | Medium | [No Idea!](https://www.hackerrank.com/challenges/no-idea/problem) | [NoIdea.py](LANGUAGE%20PROFICIENCY/Python/Sets/NoIdea.py)
140140
| Sets | Easy | [Symmetric Difference](https://www.hackerrank.com/challenges/symmetric-difference/problem) | [SymmetricDifference.py](LANGUAGE%20PROFICIENCY/Python/Sets/SymmetricDifference.py)
141141
| Sets | Easy | [Set .discard(), .remove() & .pop()](https://www.hackerrank.com/challenges/py-set-discard-remove-pop/problem) | [SetDiscardRemovePop.py](LANGUAGE%20PROFICIENCY/Python/Sets/SetDiscardRemovePop.py)
142+
| Sets | Easy | [Set .union() Operation](https://www.hackerrank.com/challenges/py-set-union/problem) | [SetUnion.py](LANGUAGE%20PROFICIENCY/Python/Sets/SetUnion.py)
143+
| Sets | Easy | [Set .intersection() Operation](https://www.hackerrank.com/challenges/py-set-intersection-operation/problem) | [SetIntersection.py](LANGUAGE%20PROFICIENCY/Python/Sets/SetIntersection.py)
144+
| Sets | Easy | [Set .difference() Operation](https://www.hackerrank.com/challenges/py-set-difference-operation/problem) | [SetDifference.py](LANGUAGE%20PROFICIENCY/Python/Sets/SetDifference.py)
145+
| Sets | Easy | [Set .symmetric_difference() Operation](https://www.hackerrank.com/challenges/py-set-symmetric-difference-operation/problem) | [SetSymmetricDifference.py](LANGUAGE%20PROFICIENCY/Python/Sets/SetSymmetricDifference.py)
146+
| Sets | Easy | [Set Mutations](https://www.hackerrank.com/challenges/py-set-mutations/problem) | [SetMutations.py](LANGUAGE%20PROFICIENCY/Python/Sets/SetMutations.py)
147+
| Sets | Easy | [The Captain's Room](https://www.hackerrank.com/challenges/py-the-captains-room/problem) | [TheCaptiansRoom.py](LANGUAGE%20PROFICIENCY/Python/Sets/TheCaptiansRoom.py)
148+
| Sets | Easy | [Check Subset](https://www.hackerrank.com/challenges/py-check-subset/problem) | [CheckSubset.py](LANGUAGE%20PROFICIENCY/Python/Sets/CheckSubset.py)
149+
| Sets | Easy | [Check Strict Superset](https://www.hackerrank.com/challenges/py-check-strict-superset/problem) | [CheckStrictSuperset.py](LANGUAGE%20PROFICIENCY/Python/Sets/CheckStrictSuperset.py)
142150

143151
# Shell
144152

0 commit comments

Comments
 (0)