You are viewing a single comment's thread. Return to all comments →
But, thanks to Jekus' post above, here's a much more efficient solution:
Scanner in = new Scanner(System.in); int t = in.nextInt(); for (int i = 0; i < t; i++) { int n = in.nextInt(); int k = in.nextInt(); if ((k-1 | k) <= n) { System.out.println(k-1); } else { System.out.println(k-2); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 29: Bitwise AND
You are viewing a single comment's thread. Return to all comments →
But, thanks to Jekus' post above, here's a much more efficient solution: