Service NowOA #1
Find Max Minimum Value Using K Elements
估计困难评测数据准备中,可先阅读题面
考点(AI 标注)背包计数
You have given 2 Arrays Shop1 of size N and shop2 of size N and an Integer K. You have to find the maximum, minimum value using K elements from both given arrays.
Calculate the minimum of the sum of K elements from both arrays, i.e., Min (a1+a2+...+ak, b1+b2+...+bk).
Function Description
Complete the function findMaxMinValueUsingKElements in the editor.
findMaxMinValueUsingKElements has the following parameters:
-
int[] shop1: an array of integers representing the first shop
-
int[] shop2: an array of integers representing the second shop
-
int k: the number of elements to consider Returnsint: the maximum minimum value usingKelements
Constraints
A mysterous urban legend for now
Example 1
Input:
shop1 = [6, 3, 6, 5, 1]
shop2 = [1, 4, 5, 9, 2]
k = 3
Output:
15
Explanation: Min(6+6+5, 1+5+9) = 15.
Example 2
Input:
shop1 = [10, 2, 4]
shop2 = [1, 9, 6]
k = 1
Output:
4
Explanation: Min(4, 6) = 4.