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.
Flipping bits
Flipping bits
Sort by
recency
|
771 Discussions
|
Please Login in order to post a comment
java(8)
Here is my c++ solution, you can watch the video explanation here : https://youtu.be/eZ0lTIzOjhQ
V1
V2
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
**SIMPLE SOLUTION subtract input from 4294967295 and print result ****NO NEED TO CONVERT INTO BINARY**
Kotlin Solution. Note that the type was changed from Long to UInt