题目描述
Given an array arr[] of N positive elements. The task is to find the Maximum AND Value generated by any pair of elements from the array.
Note: AND is bitwise '&' operator.
Example 1:
Input : Arr[] = {4, 8, 12, 16}
Output : 8
Explanation:
Pair (8,12) has the Maximum AND Value
i.e. 8.
Example 2:
Input : Arr[] = {4, 8, 16, 2}
Output : 0
Your Task:
The input is already taken care of by the driver code. You only need to complete the function maxAND() that takes an array (arr), size of Array (n) as parameter and return the maximum AND value of pair. The driver code takes care of the printing.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(1).
Constraints:
1 <= N <= 510^{5}
1 <= arr[i] <= 510^{5}
输入格式
见题面
输出格式
见题面