Skip to content

Commit 2416352

Browse files
Added counting-bits
1 parent 3a7c62b commit 2416352

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

counting_bits.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public:
3+
vector<int> countBits(int num) {
4+
vector<int> ans;
5+
for(int i=0; i<=num; i++){
6+
ans.push_back(__builtin_popcount(i));
7+
}
8+
return ans;
9+
}
10+
11+
};

0 commit comments

Comments
 (0)