알고리즘/codefights
19>rangeBitCount
Diademata
2021. 4. 17. 17:09
반응형
For a = 2 and b = 7, the output should be |
code>>
int rangeBitCount(int a, int b) {
auto count = 0;
for (int i = a; i <= b; ++i)
{
std::bitset<4> bit(i);
count += bit.count();
}
return count;
}
반응형