text: Split an array into subarrays with maximum Bitwise XOR of their respective Bitwise OR values | C ++ 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
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; int MaxXOR ( int arr [ ] , int N ) { int res = 0 ; for ( int i = 0 ; i < N ; i ++ ) { res |= arr [ i ] ; } return res ; } int main ( ) { int arr [ ] = { 1 , 5 , 7 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << MaxXOR ( arr , N ) ; return 0 ; }