• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
November 01, 2023 |500 Views
SDE Sheet - Bit Difference
  Share  1 Like
Description
Discussion

This video is part of the Bit Manipulation section under the GFG SDE Sheet.

In this problem, we are given two numbers A and B. The task is to count the number of bits needed to be flipped to convert A to B.

Example :

Input: A = 10, B = 20
Output: 4

Explanation:
A  = 01010
B  = 10100
As we can see, the bits of A that need to be flipped are 01010. If we flip these bits, we get 10100, which is B.

Try it out before watching the implementation of the problem in the video. We recommend watching the video, even if you can solve the problem. You may discover something new. All the best!!!

Do check out:-
Article: https://www.geeksforgeeks.org/sum-of-bit-differences-among-all-pairs/
Problem: https://practice.geeksforgeeks.org/problems/bit-difference-1587115620/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/

Read More