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.
1 XOR anything gives its inverse.
Hence, for 32 bit unsigned numbers ,
(2^32 -1) XOR 'the given number' flips each bit.
I guess its possibly the fastest way to get this done.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Flipping bits
You are viewing a single comment's thread. Return to all comments →
1 XOR anything gives its inverse. Hence, for 32 bit unsigned numbers , (2^32 -1) XOR 'the given number' flips each bit. I guess its possibly the fastest way to get this done.