02.
Problem statement
You are required to implement the following function:
int MinMaxInTwoArrays(int arri[], int arr2[], int lent, int led, it
k);
The function accepts two integer arrays 'arri' of length lenta
length 'len2' and an integer 'k' as its arguments. Let the count of me
greater than 'k' in array 'arri' be Y and the count of numbers
'k'in array 'art2' be 'y! You are required to return the maximum
y from the function.
Assumption: 'leni, Ven2 > 0
Example
Input:
arri: 9 16 12 5 15
arr2: 14 7 22 532 77
k9
Output:
3
Explanation
3 integers in the array / 16, 2
in the array / 14 22 22
retumed
The custom input format for the above
5
Answers
Answer:
arr1=[]
arr2=[]
count=0
count1=0
k=int(input('enter the k'))
l1=int(input('enter length in arr1'))
for i in range(l1):
n=int(input('enter the element in arr1'))
arr1.append(n)
print(arr1)
l2=int(input('enter length in arr2'))
for i in range(l2):
m=int(input('enter theelement in arr2'))
arr2.append(m)
print(arr2)
for j in (arr1):
if k < j:
count+=1
# print(count)
for i in (arr2):
if k > i:
count1=count1+1
#print(count1)
if count > count1:
print(count)
else:
print(count1)
Step-by-step explanation:
The sum of the first and second arrays' highest and lowest values.
Get the product of the first array's max element and the second array's min element given two arrays.
Consider the following examples:
1. Input: arr1[] = 5, 7, 9, 3, 6, 2; arr2[] = 1, 2, 6, -1, 0, 9; arr1[] = 5, 7, 9, 3, 6, 2; arr2[] = 1, 2, 6, -1, 0, 9; arr1[] = 5, 7, 9, 3, 6, 2; arr2[] = 1, 2, 6, -1, 0,
The first array's maximum element is 9 and the smallest element is 0.
The biggest element in the first array is 9, whereas the lowest value in the second array is -1. These two integers add up to -9.
2. arr1[] = 1, 4, 2, 3, 10, 2; arr2[] = 4, 2, 6, 5, 2, 9; arr1[] = 1, 4, 2, 3, 10, 2; arr1[] = 1, 4, 2, 3, 10, 2; arr2[] = 4, 2, 6, 5, 2, 9; arr1[] = 1, 4, 2, 3, 10, 2; arr1[] = 1, 4, 2, 3, 10, 2; arr1[] = 1, 4, 2, 3, 10, 2; arr1[] = 1, 4, 2,