Skip to content

Commit 6e7eb27

Browse files
committed
Update counting-bits.cpp
1 parent 6b18254 commit 6e7eb27

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

C++/counting-bits.cpp

Lines changed: 1 addition & 1 deletion
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)