Challenge 3: Power of 2
In this lesson, we will try to check if the given number is a power of 2. We solve this by writing an efficient algorithm that takes an optimal amount of time.
Introduction
Let’s do another challenging question to check your understanding of Bitwise operators.
For example:
Input: 4
Output: True (As 4 is 2^2)
Input: 12
Output: False
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.