• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
October 30, 2023 |1.1K Views
PROBLEM OF THE DAY: 29/10/2023 | Check whether K-th bit is set or not
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Siddharth Hazra. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Bit Magic but will also help you build up problem-solving skills.

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: 
The binary representation of 4 is 100, in which the 0th index bit from LSB is not set. So, return false.

Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/check-whether-k-th-bit-is-set-or-not-1587115620/1
Solution IDE Link: https://ide.geeksforgeeks.org/online-cpp-compiler/255dbb66-e03a-47be-a004-8535dd9ace38

Read More