Skip to content

Commit f95e5bd

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent bfa433e commit f95e5bd

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,54 @@
1-
'''
2-
A list that has the common distinct element from both arrays and
3-
if there are repetitions of the element then only one occurrence
1+
"""
2+
A list that has the common distinct element from both arrays and
3+
if there are repetitions of the element then only one occurrence
44
is considered, known as the union of both arrays.
55
6-
A list that has common distinct elements from both arrays,
6+
A list that has common distinct elements from both arrays,
77
is the intersection of both arrays.
88
99
1010
Example:
1111
Input: a[] = {1, 2, 2, 3, 4, 8, 10}, b[] = {4, 6, 3, 1}
1212
Output: {1, 2, 3, 4, 6, 8, 10}
13-
Explanation: 1, 2, 3, 4, 6, 8 and 10 is the union of
13+
Explanation: 1, 2, 3, 4, 6, 8 and 10 is the union of
1414
elements present in array a[] and array b[].
1515
1616
Input: a[] = {1, 2, 2, 3, 4, 8, 10}, b[] = {4, 6, 3, 1}
1717
Output: {1, 2, 3, 4}
18-
Explanation: 1, 2, 3, and 4 are the intersection(common elements)
18+
Explanation: 1, 2, 3, and 4 are the intersection(common elements)
1919
of elements present in array a[] and array b[].
2020
2121
https://www.geeksforgeeks.org/union-and-intersection-of-two-sorted-arrays-2/
2222
2323
24-
'''
24+
"""
2525

26-
#Taking input lists from user
26+
# Taking input lists from user
2727

28-
a=list(map(int,input('Enter elements of first list:').split()))
29-
b=list(map(int,input('Enter elements of second list:').split()))
28+
a = list(map(int, input("Enter elements of first list:").split()))
29+
b = list(map(int, input("Enter elements of second list:").split()))
3030
# Example Input
31-
#Enter elements of first list: 3 4 6 4 4 6 7 41
32-
#Enter elements of second list: 78 3 5 7 -1 9 2 -5
31+
# Enter elements of first list: 3 4 6 4 4 6 7 41
32+
# Enter elements of second list: 78 3 5 7 -1 9 2 -5
3333

3434

35-
36-
'''bitwise or (|) between the sets of both arrays
35+
"""bitwise or (|) between the sets of both arrays
3736
to find union and assign it into a variable A
3837
in the form of lists.
3938
bitwise and (&) between the sets of both arrays
4039
to find intersection and assign it into a variable A
4140
in the form of lists.
42-
'''
43-
41+
"""
4442

45-
A=list(set(a)|set(b))
46-
B=list(set(a)&set(b))
4743

44+
A = list(set(a) | set(b))
45+
B = list(set(a) & set(b))
4846

4947

50-
print('Union of the arrays:',A)
51-
print('intersection of the arrays:',B)
48+
print("Union of the arrays:", A)
49+
print("intersection of the arrays:", B)
5250

53-
#Output
54-
'''Union of the arrays: [2, 3, 4, 5, 6, 7, 41, 9, 78, -5, -1]
51+
# Output
52+
"""Union of the arrays: [2, 3, 4, 5, 6, 7, 41, 9, 78, -5, -1]
5553
intersection of the arrays: [3, 7]
56-
'''
54+
"""

0 commit comments

Comments
 (0)