We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Maximizing XOR
Maximizing XOR
Sort by
recency
|
489 Discussions
|
Please Login in order to post a comment
Here is my easy and straitghforward solution, you can watch video here : https://youtu.be/pCU8W_ofvDg
Haskell
![]( def maximizingXor(l, r): new_results = 0 for i in range(l, r + 1): for j in range(l,r + 1): old_result = i ^ j if old_result >= new_results: new_results = old_result return new_resultshttps://)
Python, one-liner:
return 2**(1+int(math.floor(math.log(l^r, 2.0))))-1