Problem of the day
The problem is to find the rightmost bit of a non-negative number 'N' that is currently unset (i.e., has a value of 0) in its binary representation and set it to 1.
Return the number after setting the rightmost unset bit of 'N'. If there are no unset bits in N's binary representation, then the number should remain unchanged.
N = 5
Output: 7
Explanation: The binary representation of 5 is 101. After setting the rightmost unset bit it becomes 111 which is 7.
The first line of each test case contains an integer 'N’.
Output Format:
The output contains an integer, which is the number after setting the rightmost unset bit.
Note:-
You don’t need to print anything. Just implement the given function.
10
11
N=10
The binary representation of 10 is 1010. After setting the rightmost unset bit it becomes 1011 which is 11.
7
7
N=7
The binary representation of 7 is 111. As there is no unset bit it remains the same.
1 <= N <= 10^9
Time Limit: 1 sec