• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
October 25, 2023 |150 Views
SDE Sheet - Check whether K-th bit is set or not
  Share   Like
Description
Discussion

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

In this problem, we are given, a number N and a bit number K, check if Kth index bit of N is set or not. A bit is called set if it is 1. Position of set bit '1' should be indexed starting with 0 from LSB side in binary representation of the number.
Note: Index is starting from 0. You just need to return true or false, driver code will take care of printing "Yes" and "No".

Example :

Input: 
N = 4
K = 0
Output: 
No

Explanation: 
Binary representation of 4 is 100, in which 0th index bit from LSB is not set. So, return false.

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/check-whether-k-th-bit-set-not/
Problem: https://practice.geeksforgeeks.org/problems/check-whether-k-th-bit-is-set-or-not-1587115620/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/

Read More