Hello Coders, Recently In online test of BNY company these two questions were asked. It will be great if someone can give approach to solve these questions.
- Given two arrays of integer A and B of length n. We have to choose k indexes such that min(Sum of elements of A at chosen indexes, sum of elements of B at chosen indexes) is maximized. We have to return that maximum sum.
1<=A[i],B[i],n<=50
1<=k<=n
- Given integer array A of length n. Initially our power will be 0. Now in one operation we can choose two indexes i and j, i != j. Now we can add A[i] ^ A[j] to power and have to remove any one element. So after n — 1 operation we will be left with only 1 element. At that point we have to stop the process. We have to return what is the maximum power we can collect.
1 <= n <= 1000
1 <= A[i] <= 10^9