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.
No need for complex code. Flipping bits meaning is to just get the biggest number in that requested bit and then substract those with the number asked in the question. For ex. : the question wanted a 32 bit, so the max number would be 4294967295. Now to get what the flipping bits of lets say 10 in 32 bit and return it to decimal, just do 4294967295 - 10 which is 4294967285, and there you go the decimal version of its flipping bit.
Here is in Go
funcflippingBits(nint64)int64{// Write your code herereturn4294967295-n}
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 →
No need for complex code. Flipping bits meaning is to just get the biggest number in that requested bit and then substract those with the number asked in the question. For ex. : the question wanted a 32 bit, so the max number would be 4294967295. Now to get what the flipping bits of lets say 10 in 32 bit and return it to decimal, just do 4294967295 - 10 which is 4294967285, and there you go the decimal version of its flipping bit.
Here is in Go