
Maximise the OR Sum Problem Statement
You are provided with two arrays of positive integers. The goal is to select two sub-arrays of the same length, one from each of the provided arrays, such that the sum of the bitwise OR of these sub-arrays is maximized. Return the maximum sum possible.
Example:
Input:
First array: arr1 = [1,5,8,4]
Second array: arr2 = [3,7,16,1]
Output:
26
Explanation:
Select the sub-array {5,8} from the first array (arr1), and the sub-array {7,16} from the second array (arr2). The OR sum is calculated as 13 + 23 = 26, which is the maximum possible.
Constraints:
1 <= T <= 10
1 <= N <= 10^5
1 <= arr1[i], arr2[i] <= 10^5
- Time Limit: 1 sec.

AnswerBot
3d

Select two sub-arrays of the same length from two arrays to maximize the sum of bitwise OR.
Iterate through all possible sub-arrays of the same length from both arrays.
Calculate the bitwise OR sum for ...read more

Help your peers!
Add answer anonymously...
Popular interview questions of Software Engineer
>
Elgin Industries Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app