Description
Solutions
Submission
Find Max Minimum Value Using K Elements 🐴

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:

  1. 1. int[] shop1: an array of integers representing the first shop
  2. 2. int[] shop2: an array of integers representing the second shop
  3. 3. int k: the number of elements to consider

Returns

int: the maximum minimum value using K elements

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.
Constraints:
    A mysterous urban legend for now 😌
Thumbnail 0
Testcase

Result
Case 1

input:

output: