Submit | All submissions | Best solutions | Back to list |
MAXXOR - Find the max XOR value |
You have two integers L and R, and you are required to find the maximum xor value of a and b where L ≤ a ≤ R and L ≤ b ≤ R.
Input
Two integers in a line. L, R ≤ 109.
Output
One integer, the answer.
Example
Input: 1 10 Output: 15
Added by: | SCaffrey |
Date: | 2015-12-03 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 GOSU JS-MONKEY |
Resource: | https://www.hackerrank.com/challenges/maximizing-xor |
hide comments
|
|||||
2018-05-01 09:15:42
so what should do to solve it not using the formula??? |
|||||
2017-07-10 12:12:49
AC in One Go :) My tiny penis is throbbing with excitement! Last edit: 2021-01-18 08:37:13 |
|||||
2017-06-07 21:50:00
@karthik1997: try your formula for L=8 and R=10. your formula is wrong. |
|||||
2017-01-26 16:42:27
weak test cases my code got ac. but for input 1 1 it shows 1 but ans should be 0. :D |
|||||
2016-06-10 18:44:17
Nice Question .Ignore the formula.Try on your own. |
|||||
2016-06-07 22:09:06
don't use this formula.....its wrong for many cases...but it works here....use logic to get the beauty of ques. AC :-) |
|||||
2016-04-16 21:34:21
awesome problem awesome concept after a long time AC in one go...<3. |
|||||
2016-01-28 16:56:22 topke
Yea very weak test cases that's why formula is passing. Try 100 120 i bet half of these solutions won't pass. Plus it would be nice from author to remove formula from comments. |
|||||
2016-01-04 21:00:34
weak test cases |
|||||
2016-01-04 17:27:32 Sayak Haldar
@karthik1997: your formula is actually wrong. Since, the testcases are weak your solution got AC (if you strictly follow the formula) |