Question: AND OR subarray You are given two arrays A and B of length N Task Determine the length largest subarray of A and B such

AND OR subarray
You are given two arrays A and B of length N
Task
Determine the length largest subarray of A and B such that bitwise OR of A[i].A[i+1]dotsA[j] and bitwise-AND of B[l],B[i+1]dotsB[j] is equal
Example
Assumptions
N=4
A=[2,1,3,3]
B=[15,3,7,11]
Approach
There are two possible ways to get answer 3 which are.
OR(2,1,3)=AND(15,3,7)
OR(1,3,3)=AND(3,7,11)
The largest subarray length among both is 3.
Thus, the answer is 3.
Function description
Complete the function solve provided in the editor. This function takes the following 3 parameters and returns the required answer.
 AND OR subarray You are given two arrays A and B

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!