This video is part of the Bit Manipulation section under the GFG SDE Sheet.
In this problem, we are given, an integer N and an integer D, rotate the binary representation of the integer N by D digits to the left as well as right and return the results in their decimal representation after each of the rotation.
Note: Integer N is stored using 16 bits. i.e. 12 will be stored as 0000000000001100.
Example :
Input:
N = 28, D = 2
Output:
112
7
Explanation:
28 in Binary is: 0000000000011100
Rotating left by 2 positions, it becomes 0000000001110000 = 112 (in decimal).
Rotating right by 2 positions, it becomes 0000000000000111 = 7 (in decimal).
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/rotate-bits-of-an-integer/
Problem: https://practice.geeksforgeeks.org/problems/rotate-bits4524/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/