Maximum XOR | Program to obtain maximum XOR value sub - array ; function to calculate maximum XOR value ; Return ( 2 ^ c - 1 ) ; driver program
#include <bits/stdc++.h> NEW_LINE using namespace std ; int maxXOR ( int n , int k ) { int c = log2 ( n ) + 1 ; return ( ( 1 << c ) - 1 ) ; } int main ( ) { int n = 12 ; int k = 3 ; cout << maxXOR ( n , k ) ; return 0 ; }