Split an array into subarrays with maximum Bitwise XOR of their respective Bitwise OR values | Function to find the bitwise OR of array elements ; Stores the resultant maximum value of Bitwise XOR ; Traverse the array arr [ ] ; Return the maximum value res ; Driver code
function MaxXOR ( arr , N ) { var res = 0 ; for ( var i = 0 ; i < N ; i ++ ) { res |= arr [ i ] ; } return res ; } var arr = [ 1 , 5 , 7 ] ; var N = arr . length ; document . write ( MaxXOR ( arr , N ) ) ;