-
Notifications
You must be signed in to change notification settings - Fork 22
/
find first set bit
44 lines (35 loc) · 947 Bytes
/
find first set bit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
Given an integer an N. The task is to print the position of first set bit found from right side in the binary representation of the number.
Input:
The first line of the input contains an integer T, denoting the number of test cases. Then T test cases follow. The only line of the each test
case contains an integer N.
Output:
For each test case print in a single line an integer denoting the position of the first set bit found form right side of the binary
representation of the number. If there is no set bit print "0".
Constraints:
1 <= T <= 200
0 <= N <= 106
Example:
Input:
2
18
12
Output:
2
3
Explanation:
Testcase 1: Binary representation of the 18 is 010010, the first set bit from the right side is at position 2.
*/
#include <iostream>
using namespace std;
int main() {
int t; cin>>t; while(t--)
{
string s;
cin>>s;
unordered_map<string,int> freq;
for(int i=0;i<100000;i++) freq[i]=0;
while()
}
return 0;
}