


You are given a number N. You need to return the position of the rightmost set bit.
For example:If the given number is 10 with the binary representation: 1010
The rightmost set bit would be 2 (counted from right).
The first line of input contains a single integer T, representing the number of test cases or queries to be run.
Then the T test cases follow.
The first line of each test case contains a single integer N.
Output Format:
For each test case, print the position of the rightmost set bit.
1 ≤ T ≤ 100
1 ≤ N ≤ 10^9
Time Limit : 1 sec
Note:
You are not required to print the expected output, it has already been taken care of. Just implement the function.
3
10
3
8
2
1
4
For the first test case, the binary representation of 10 is 1010. So answer is 2
For the second test case, the binary representation of 3 is 11. So answer is 1
For the third test case, the binary representation of 8 is 1000. So answer is 4
3
4
18
24
3
2
4
Check each bit from right to left
O(log2(N))
As in the worst case, all the bits would be checked. This is because the number of bits in the binary representation of N would be log2(N)
O(1)
In the worst case, no extra constant space is required.