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.
This solution generates the correct answer in a sly but non-intuitive manner. So unintuitive that I believe the provided explanation is actually wrong. (correct me here if i'm mistaken please). The solution doesn't shift the bits to the right at all. Notice '>>> 0'. If it shifted the bits to teh right than the operand after >>> would be greater than 0. What >>> 0 does is cast the first operand expression, ~integer, to a 32 bit integer Number rather than a two's complement.
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 →