Select K Paired Indices for Maximum Score
Problem statement
Select exactly k shared indices from two equal-length arrays. The score is the sum of selected values from first multiplied by the minimum selected value from second.
Return the maximum score.
Function
maximumPairedScore(first: int[], second: int[], k: int) → intExamples
Example 1
first = [1,3,3,2]second = [2,1,3,4]k = 3return = 12Case 1 exercises the documented deterministic contract.
Example 2
first = [4,2,3,1,1]second = [7,5,10,9,6]k = 1return = 30Case 2 exercises the documented deterministic contract.
Example 3
first = [2,1,14,12]second = [11,7,13,6]k = 3return = 168Case 3 exercises the documented deterministic contract.
Constraints
1 <= k <= first.length == second.length <= 100000.- All values are positive integers.
- The answer fits a signed 32-bit integer.