Maximum XOR | Program to obtain maximum XOR value sub - array ; function to calculate maximum XOR value ; Return ( 2 ^ c - 1 ) ; Driver Code
import java . lang . * ; class GFG { static int maxXOR ( int n , int k ) { int c = ( int ) ( Math . log ( n ) / Math . log ( 2 ) ) + 1 ; return ( ( 1 << c ) - 1 ) ; } public static void main ( String [ ] args ) { int n = 12 ; int k = 3 ; System . out . println ( maxXOR ( n , k ) ) ; } }