Add solution to 'a lot' of problems

This commit is contained in:
Arkaprabha Chakraborty
2022-08-01 13:28:06 +05:30
parent 20d44dfd5e
commit ccc376aea0
9 changed files with 180 additions and 1 deletions

View File

@@ -0,0 +1,17 @@
#include <cmath>
#include <cstdint>
class Solution {
public:
uint32_t reverseBits(uint32_t n) {
uint32_t r = 0;
for (int i = 31; i >= 0; --i) {
if (n / (uint32_t)std::pow(2, i) >= 1) {
n -= (uint32_t)std::pow(2, i);
r += (uint32_t)std::pow(2, 31 - i);
}
}
return r;
}
};