Split an array into subarrays with maximum Bitwise XOR of their respective Bitwise OR values | Java program for the above approach ; 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
import java . lang . * ; import java . util . * ; class GFG { static int MaxXOR ( int arr [ ] , int N ) { int res = 0 ; for ( int i = 0 ; i < N ; i ++ ) { res |= arr [ i ] ; } return res ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 5 , 7 } ; int N = arr . length ; System . out . println ( MaxXOR ( arr , N ) ) ; } }