Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Check if a given number is a power of two using bitwise operations.

Hard

Problem Statement

Check if a given number is a power of two using bitwise operations.

Sample Input

8

Sample Output

true

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
def power_of_two?(num) # Your code here end
Log in or sign up to run or submit your code.Log inSign up
Input
8
Expected Output
true