Skip to content

Commit 9b8db27

Browse files
committed
Update counting-bits.cpp
1 parent 47b4f3b commit 9b8db27

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

C++/counting-bits.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Solution {
66
vector<int> countBits(int num) {
77
vector<int> res{0};
88
for (int i = 1; i <= num; ++i) {
9-
res.emplace_back(res[i >> 1] + (i & 1));
9+
res.emplace_back((i & 1) + res[i >> 1]);
1010
}
1111
return res;
1212
}

0 commit comments

Comments
 (0)