Given an array arr of N positive elements. The task is to find the Maximum AND Value generated by any pair of element from the array.
Note: AND is bitwise '&' operator.
The first line of the input contains a single integer T, denoting the number of test cases. Then T test cases follow. Each test-case has two lines of the input, the first line contains an integer denoting the size of an array N and the second line of input contains N positive integers
For each testcase, print Maximum AND Value of a pair in a separate line.
1 <=T <= 100
1 <= N <= 5*105
1 <= arr[i] <= 5*105
4 8 12 16
4 8 16 2
Testcase 1: Pair (8,12) has the Maximum AND Value i.e. 8.
Testcase 2: Maximum AND Value is 0.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.