@@ -0,0 +1,920 @@
+import java.io.*;%0Aimport java.util.*;%0Aimport java.text.*;%0Aimport java.math.*;%0Aimport java.util.regex.*;%0A%0Apublic class Solution %7B%0A  // brute-force approach just iterate over all pairs of integers and print max%0A  static int maxXor(int l, int r) %7B%0A    int max = 0;%0A    for (int i = l; i %3C r; i++) %7B%0A      for (int j = i + 1; j %3C= r; j++) %7B%0A        max = Math.max(max, i %5E j);%0A      %7D%0A    %7D%0A    return max;%0A  %7D%0A%0A  // bit-shift approach, to '%7C' is used to maximize XOR difference for every bit.%0A  static int maxXor2(int l, int r) %7B%0A    int v = l %5E r;%0A    v %7C= v %3E%3E 1;%0A    v %7C= v %3E%3E 2;%0A    v %7C= v %3E%3E 4;%0A    v %7C= v %3E%3E 8;%0A    v %7C= v %3E%3E 16;%0A    return v;%0A  %7D%0A%0A  public static void main(String%5B%5D args) %7B%0A    Scanner in = new Scanner(System.in);%0A    int res;%0A    int _l;%0A    _l = Integer.parseInt(in.nextLine());%0A%0A    int _r;%0A    _r = Integer.parseInt(in.nextLine());%0A%0A    res = maxXor2(_l, _r);%0A    System.out.println(res);%0A  %7D%0A%7D%0A

add maximize xor solution