you are given an array arr of length N. The bitvalue of two numbers (A,B) is defined by A-(A&B)
The BitValue of the array is defined as
take the bitvalue of a0, and a1, then take the result's bitvalue with the next number i.e a2 and so on till an-1
task:-
Determine the maximum bitvalue of the array if the numbers can be re arranged
n=4
arr=[4,0,11,6]
the array that gives the maximum bitvalue is [11,6,4,0]
The bitValue of the array is
bit value of 11, 6 which is(11-(11&6))=(11-2)=9
then bitValue of 9 and 4 which is 9
finally bitvalue of 9 and 0 which is 9.
thus the maximum bitValue of the array is 9
thus the ans is 9
arr=[4,0,5,3,1] ans=2;