Longest OR
There is an array of n integers, arr, and two integers mn and mx.
For each of arr's subarrays, find the binary value of the bitwise OR of all elements. If the number of 1 bits is between mn and mx, inclusive, it's a good subarray.
Determine the length of the longest good subarray.
Note: A subarray is any segment of adjacent elements in an array. For example, if arr = [1, 2, 3], [1, 2] is a subarray but [1, 3] is not.
Complete the function longestGoodSubarray in the editor.
longestGoodSubarray has the following parameters:
int arr[n]: an array of integersint mn: an integerint mx: an integer
Returns
int: the length of the longest good subarray
1Example 1
Constraints
Limits and guarantees your solution can rely on.
Unknown so far. If you happen to know about it, feel free to contact Groot in our server. TYVM!