forked from srinathr91/TestJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
45 lines (32 loc) · 808 Bytes
/
Solution.java
File metadata and controls
45 lines (32 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
/*
* Complete the function below.
*/
static int maxXor(int l, int r) {
int res=-1;
for(int a=l;a<=r;a++){
for(int b=a;b<=r;b++){
if((a^b)>res){
res=a^b;
}
}
}
return res;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int res;
int _l;
_l = Integer.parseInt(in.nextLine());
int _r;
_r = Integer.parseInt(in.nextLine());
res = maxXor(_l, _r);
System.out.println(res);
in.close();
}
}