Loading...

Check set bits
Basic Accuracy: 63.77% Submissions: 5103 Points: 1

Given a number N. You have to check whether every bit in the binary representation of the given number is set or not.

Example 1:

Input:
N = 7
Output:
1
Explanation:
Binary for 7 is 111 all the
bits are set so output is 1


Example 2:

Input:
N = 8
Output:
0
Explanation:
Binary for 8 is 1000 all the
bits are not set so output is 0.

Your Task:
You don't need to read input or print anything. Your task is to complete the function isBitSet() which takes an integer N as input parameters and returns 1 if all the bits in N's binary representation is set or return 0 otherwise.

Expected Time Complexity: O(1)
Expected Space Complexity: O(1)

Constraints:
0<=N<=100000

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

My Submissions:

Login to access your submissions.

Check set bits