We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 47b4f3b commit 9b8db27Copy full SHA for 9b8db27
C++/counting-bits.cpp
@@ -6,7 +6,7 @@ class Solution {
6
vector<int> countBits(int num) {
7
vector<int> res{0};
8
for (int i = 1; i <= num; ++i) {
9
- res.emplace_back(res[i >> 1] + (i & 1));
+ res.emplace_back((i & 1) + res[i >> 1]);
10
}
11
return res;
12
0 commit comments