![]() |
VOOZH | about |
Given a non-negative number n. Find the position of rightmost unset bit in the binary representation of n, considering the last bit at position 1, 2nd last bit at position 2 and so on. If no 0's are there in the binary representation of n. then print "-1".
Examples:
Input : n = 9 Output : 2 (9)10 = (1001)2 The position of rightmost unset bit in the binary representation of 9 is 2. Input : n = 32 Output : 1
Approach: Following are the steps:
Output:
2
Time Complexity - O(1)
Space Complexity - O(1)