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.
If maxInt is the maximum value an integer can have, subtracting the original number will give you the complement. For example: If the input number is 6, that's 110 (00000110) in binary.
11111111 - 00000110 = 11111001, which, as you can see, is the input value's flipped bits.
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 →
If maxInt is the maximum value an integer can have, subtracting the original number will give you the complement. For example: If the input number is 6, that's 110 (00000110) in binary. 11111111 - 00000110 = 11111001, which, as you can see, is the input value's flipped bits.