Microsoft Online Assessment: Dual Array Index Maximization Problem
Question Details
Problem Statement Given two integer arrays, $A$ and $B$, both of length $n$, select exactly $k$ common indices. Calculate the sum of the selected elements for each array: * $Sum_A$: The sum of ele
Full Details
Problem Statement Given two integer arrays, $A$ and $B$, both of length $n$, select exactly $k$ common indices. Calculate the sum of the selected elements for each array: * $Sum_A$: The sum of elements chosen from array $A$. * $Sum_B$: The sum of elements chosen from array $B$. The objective is to select indices such that the minimum of these two sums, $\min(Sum_A, Sum_B)$, is maximized.
Example *
Input: * $A = [6, 3, 6, 5, 1]$ * $B = [1, 4, 5, 9, 2]$ * $k = 3$ *
Process: Selecting indices ${0, 2, 3}$: * $Sum_A = 6 + 6 + 5 = 17$ * $Sum_B = 1 + 5 + 9 = 15$ *
Output: The smaller value is 15. Since no other combination of 3 indices yields a higher minimum, the maximum possible answer is 15.
About This Question
This is a reported interview question from a microsoft interview for a swe role during the oa round reported in 2025.
It covers the following topics: Arrays, Backtracking, Sql .