Skip to content

Commit 79dad56

Browse files
Day 2 : Bit Manipulation Problem 2
1 parent b4773bd commit 79dad56

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
class Solution
5+
{
6+
public:
7+
vector<int> countBits(int n)
8+
{
9+
vector<int> result;
10+
11+
for (int i = 0; i <= n; i++)
12+
{
13+
result.push_back(__builtin_popcount(i));
14+
}
15+
16+
return result;
17+
}
18+
};
19+
20+
int main()
21+
{
22+
// driver code
23+
return 0;
24+
}

0 commit comments

Comments
 (0)