Welcome to the daily solving of our PROBLEM OF THE DAY with Devashish Khare. 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 Manipulation but will also help you build up problem-solving skills.
In this problem, we are given, a non-negative integer N. The task is to check if N is a power of 2. More formally, check if N can be expressed as 2x for some integer x.
Example :
Input:
N = 8
Output:
YES
Explanation:
8 is equal to 2 raised to 3 (23 = 8).
Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/power-of-2-1587115620/1
Solution IDE Link: https://ide.geeksforgeeks.org/online-python3-compiler/5d39e587-9df7-4e84-865c-fdbc63af500a