Company: Deutsche_Bank
Difficulty: medium
Debugging - Minimum required value - Java Problem Description The code editor gives you a code for the following problem statement. However, the solution fails the test cases because of code bugs. Your task is to find and fix all the bugs so that it passes all the test cases. Statement You are given two arrays, A and B, of size N consisting of non-negative integers. You have to select K numbers from B and take the bitwise OR of all the array elements in A with the chosen K numbers and add their sum. In other words, take each element from array A and add its bitwise OR with each chosen element from array B to the sum. (Note: You cannot choose two adjacent elements in B). Task You have to find the minimum value of K such that the sum is greater than or equal to M. Print -1 if impossible. Example Assumptions: A = [1, 2, 3, 4, 5] B = [2, 2, 2, 2, 2] M = 40 Approach: If K = 0, then sum = 0. If K = 1, take [2] as the chosen element from B, then sum = (1|2) + (2|2) + (3|2) + (4|2) + (5|2) = 3