Hello coder. Get ready to begin with a new problem, "Flip Bits to convert A to B" in this article.
We suggest you go through the problem's outline first to get a feel of the question.
Important Link : Problem link, Solution video
FLIP BITS TO CONVERT A TO B
Pearls don't lie on the seashore. If you want one, you must dive for it.
Hello coder. Get ready to begin with a new problem, "Flip Bits to convert A to B" in this article.
We suggest you go through the problem's outline first to get a feel of the question.
Important Link : Problem link, Solution video
The problem here deals with calculating the number of bits that are needed to be flipped to convert an integer A to B. Flipping a bit means updating a bit with value 0 to 1 or to update a bit with value 1 to 0.
For example:
57 = 0 1 1 1 0 0 1
76 =1 0 0 1 1 0 0
So we need to flip bits at positions 0, 1, 2, 4 and 6 (order is considered from left to right) to convert 57 to 76. Hence total 5 operations will be performed.
java; true";
The time complexity for the function is proportional to the number of set bits in the XOR integer.
The space complexity for the function is constant.
Reader, this was quite an easy problem. In case you have any doubts in it, we recommend you to watch its solution video.
We'll see you in the next problem. Have a great day!