Skip to content

Commit 7943b68

Browse files
committed
Runtime: 3 ms (Top 56.89%) | Memory: 7.50 MB (Top 98.08%)
1 parent 964b334 commit 7943b68

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Runtime: 3 ms (Top 56.89%) | Memory: 7.50 MB (Top 98.08%)
2+
3+
class Solution {
4+
public:
5+
vector<int> evenOddBit(int n) {
6+
int count=0;
7+
int evn=0;
8+
int odd=0;
9+
while(n)
10+
{
11+
12+
if(n&1==1)
13+
{
14+
if(count%2==0)evn++;
15+
else odd++;
16+
}
17+
18+
19+
count++;
20+
n=n>>1;
21+
}
22+
return {evn,odd};
23+
}
24+
};

0 commit comments

Comments
 (0)